JP Vossen on 29 Oct 2009 12:20:18 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] odd bash and/or less behavior


> Date: Wed, 28 Oct 2009 18:20:44 -0400
> From: Eric <eric@lucii.org>
> 
> One of the Linux systems[*] that I'm working on recently began to act
> strangely when I use the command 'less'. 
> 
> For example, typing:
> 
> /usr/bin/less index.html
> 
> ...results in the screen flashing the less "usage" text rapidly by
> followed by an immediate exit and the screen appears unchanged. 
> (if I wanted "cat >/dev/null" I would have typed: cat > /dev/null !!)
> 
> Even stranger, after that there is a file in the pwd entitled "erver:"
> that contains some control characters followed by the less help file.
> 
> I'm not sure how to troubleshoot it but I've tried:
> 
> 1.   /usr/bin/less index.html
>   erver: contains the less 'usage' text complete with control characters
> 
> 2    /usr/bin/less index.html > sample.txt
>   sample.txt contains a byte-for-byte duplicate of index.html
>   erver: is not created
> 
> 3    /usr/bin/less index.html 2> sample.txt
>    the screen flashes the less "usage" text
>    sample.txt is an empty file
>    erver: contains the less 'usage' text complete with control characters
>  
> 4    /usr/bin/less index.html > sample.txt 2&>1
>   sample.txt then contains a duplicate of index.html
>   erver: does not exist

 > $ env | grep LESS
 > LESSOPEN=| /usr/bin/lesspipe %s
 > LESSCLOSE=/usr/bin/lesspipe %s %s


Wow, that's an interesting one.  To me that sounds like a broken LESS 
environment variable, binary or lib.  You said later that you cleared 
the env variables, so that's not it unless you missed something.

What do you get with (note trailing ':'):
	$ /usr/bin/less index.html:

What does 'type -a less' give you?

What does this give you?
$ for proggy in /usr/bin/less /usr/bin/lesskey /usr/bin/lessecho \
    /usr/bin/lesspipe /usr/bin/lessfile; do file $proggy; done

On Debian Etch I get this, but both of these are my custom ones:
$ env | grep -i less
LESS=--LONG-PROMPT --LINE-NUMBERS --ignore-case --QUIET --no-init
LESSOPEN=|/opt/bin/settings/lesspipe.sh %s

On Hardy I get:
$ env | grep -i less
LESS=--LONG-PROMPT --LINE-NUMBERS --ignore-case --QUIET --no-init
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s


# Same for Etch & Hardy (but NOT Karmic!  See below.)
$ type -a less
less is /usr/bin/less

$ for proggy in /usr/bin/less /usr/bin/lesskey /usr/bin/lessecho 
/usr/bin/lesspipe /usr/bin/lessfile; do file $proggy; done
/usr/bin/less: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), 
for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for 
GNU/Linux 2.4.1, stripped
/usr/bin/lesskey: ELF 32-bit LSB executable, Intel 80386, version 1 
(SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for 
GNU/Linux 2.4.1, stripped
/usr/bin/lessecho: ELF 32-bit LSB executable, Intel 80386, version 1 
(SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for 
GNU/Linux 2.4.1, stripped
/usr/bin/lesspipe: Bourne shell script text executable
/usr/bin/lessfile: symbolic link to `lesspipe'


The last two change drastically on Karmic, less* moved to /bin with 
symlinks to that from /usr/bin.  Sigh...


You are also hard-coding the path to avoid aliases, etc., which is 
probably the right thing in this context, but FYI note that '\less' will 
avoid aliases while still using your path.  (Think about why that is 
required for something like '\unalias *'. :)


The only other think I can think of is to find a known good less binary, 
copy that to your home dir and try using that.  If it works you're 
pretty sure that the binary or libs on that system are messed up.  If 
that fails too, copy the suspected bad binary to another known good 
machine and try it.


[...]
 > DISTRIB_RELEASE=6.06
 > DISTRIB_CODENAME=dapper

Dapper desktop was end-of-life 2009-07, though server won't EoL until 
2010-06...  Maybe it's time to ave the admin update it.
http://en.wikipedia.org/wiki/List_of_Ubuntu_releases#Release_history

Good luck,
JP
----------------------------|:::======|-------------------------------
JP Vossen, CISSP            |:::======|      http://bashcookbook.com/
My Account, My Opinions     |=========|      http://www.jpsdomain.org/
----------------------------|=========|-------------------------------
"Microsoft Tax" = the additional hardware & yearly fees for the add-on
software required to protect Windows from its own poorly designed and
implemented self, while the overhead incidentally flattens Moore's Law.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug