Problems with using less

Hello,

I am having problems with using less on

Linux version 2.6.18-92.1.17.el5 (brewbuilder@hs20-bc1-7.build.redhat.com) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)). I am using csh but have the same problems on bash.

If I pipe something to less it works perfectly i.e. cat file | less

However if I do, less file, nothing happens apart from getting a new prompt line that doesn't display what I'm typing. If I type exit and press enter then I get the less output.

I was using less 394 and compiled less 429 on my system, but it had the same problem.

I looked on the less page FAQ (Less FAQ) but couldn't find anything useful.

Anybody have any idea what's wrong?

Many thanks,

Dave

When on the receiving end of a pipe less generates output. With less filename you have to play with ^V the space bar and so on. You are in interactive mode.

It's behavior depends on the terminal "type" of stdin. In a script or on the receiving end of a pipe, stdin is not a terminal. less uses termcap based on terminal type to determine base behavior when it is entered on the command line.

I'm guessing this is what you are asking.

Thanks Jim for the reply. I got your point of less behaving differently when executed directly from the terminal and when piped.

I am confused about what you mean by interactive mode. I can get into interactive mode, only when I pipe stdin to less. But when I execute less directly from the terminal, the screen is seemingly frozen and I can't get into interactive mode. When I say that the screen is seemingly frozen, I mean my typing isn't displayed, the same behaviour when you type in password. I hope I haven't confused you.

I can get out of this "frozen stage" when I type exit and then I get into the interactive mode of less. It seems like when I type "less" I change the terminal control to not display what I'm typing.

So finally I have found a solution.

It turns out that my default shell was set to csh, which is related to another thread I started http://www.unix.com/unix-dummies-questions-answers/114294-changing-default-login-shell.html\#post302354325.

I asked the system admin to change the passwd file, so that my default shell was bash. So now less works again.

So there was something strange happening with my default shell and less.

I am curious if their was a alias setup for less.

Can you see if any aliases were setup?

csh
alias less

Hi Frank,

I compiled different versions of less and ran it with (-X, which is my favourite parameter) and without additional parameters and it had the same problems outlined above.

But no there weren't any aliases set up at the time I had my problems.

Do you see any correlation between the shell and less, which might have caused my problems?

Thanks for the reply again.

Dave

no. that just sounds weird. are you 100% sure no aliases or wrapper scripts exist? Are there any less environment variables set only in csh? it's hard to say without more details but sounds like a possible environment issue.

The only aliases when it was using csh are:

$ alias
l. ls -d .* --color=tty
ll ls -l --color=tty
ls ls --color=tty
module eval `/usr/bin/modulecmd tcsh !*`
vi vim

I don't know how I could/can find wrapper scripts. As for environment variables in csh, I did this:

$ printenv | grep LESS
LESSOPEN=|/usr/bin/lesspipe.sh %s

which is the same as bash.

I wish I could give you more details, but I'm just an amateur Unix user.

Thanks again,

Dave

for kicks, can you try this?

csh
unsetenv LESSOPEN
less your.file

Unfortunately (or fortunately), once the sys admin changed my passwd entry on the LDAP server (?) back to /bin/bash (it was previously on /bin/csh when I did getent), less works on csh. So I can't replicate the error.