Thelete na sas hackepsw sta grhgora?

Christos Ricudis ricudis at komodino.itc.auth.gr
Wed Oct 18 11:04:34 EEST 2006


Fotis Georgatos wrote:
>>> To oti *to dokimases ontws* kai *to eides ontws*, den eimai... me hackepses!
>>>       
>> To `hack' eksartatai apo polla pragmata:
>>
>>     a) Apo thn yparksh tou LESSOPEN sto environment tou root
>>     
>
> [root at ce05 root]# set|grep LESS
> LESSOPEN='|/usr/bin/lesspipe.sh %s'
>   

komodino:[root]/home/ricudis# printenv | grep -i less
LESSCHARDEF=8bcccbcc18b.
LESS=-MM

Wstoso sto debian moy, akoma kai meta to

komodino:[root]/home/ricudis# eval "$(lessfile)"
komodino:[root]/home/ricudis# printenv | grep -i less
LESSCHARDEF=8bcccbcc18b.
LESS=-MM
LESSOPEN=/usr/bin/lessfile %s
LESSCLOSE=/usr/bin/lessfile %s %s
komodino:[root]/home/ricudis# echo koko lala >>~/.bashrc

ola synexizoun na symperiferontai opws prin.

Epishs, sto debian einai documented sumperifora, sto man page tou 
lessfile :

       Sometimes,  less  does not display the contents file you want to 
view but
       output that is produced by your login scripts (~/.bashrc or  
~/.bash_pro-
       file).  This  happens  because  less  uses  your current shell to 
run the
       lesspipe filter. Bash first looks for the variable $BASH_ENV in 
the envi-
       ronment  expands  its value and  uses the expanded value as the 
name of a
       file to read and execute. If this file produces any output less 
will dis-
       play  this.  A way to solve this problem is to put the following 
lines on
       the top of your login script that produces output:

         if [ -z "$PS1" ]; then
             exit
         fi

       This tests whether the prompt variable $PS1 is set and if it 
isn't (which
       is the case for non-interactive shells) it will exit the script.



Sas exw ksanapei poso mou th spane ta distributions pou prospa8oun na 
"kanoun th zwh tou xrhsth pio eykolh" me hli8ia kolpa tou styl lesspipe. 
Otan lew "less koko.gz" ENNOW "less koko.gz", kai oxi "preprocess it 
before lessing it just in case it is a compressed file with ascii art 
pr0n". An 8elw na kanw "tar -tvvf koko.tar" 8a kanw "tar -tvvf 
koko.tar", DEN 8elw na mou to kanei h less epeidh nomizei oti ayto 8elw 
na kanw.

An bebaia mas aresei h lessfile, 8elei akoma arketh beltiwsh :


                # Decode file for less
                case `echo "$1" | tr '[:upper:]' '[:lower:]'` in
                     
                        *.tar.bz2)
                                if [ -x "`which bunzip2`" ]; then
                                        bunzip2 -dc "$1" | tar tvvf -
                                else echo "No bunzip2 available"; fi ;;


to opoio, FYSIKA, 8a eprepe na htan :



                # Decode file for less

                if [ ! -x "`which tr`" ] ; then
                        echo "No tr available";
                else
                        case `echo "$1" | tr '[:upper:]' '[:lower:]'` in
                                *.tar.bz2)
                                    if [ ! -x "`which grep`" -o ! -x 
"`which tar`" -o ! -x "`which cut`" -o ! -x "`which file`" -o ! -x 
"`which which`" ] ; then
                                       echo "This is no 31337 UNIX!";
                                    else
                                       if [ -x "`which bunzip2`" ]; then
                                           FILETYPE=`file $1 | cut -f2 -d:`;
                                           if [ "`echo $FILETYPE | grep 
bzip2`" ] ; then
                                               bunzip2 -dc "$1" | tar tvvf -
                                           else
                                               echo 
"\$SYS-ERR-39423-PATERNALISTIC-FILEPIPE-WRONGFILETYPE : SOMEBODY PLAYS 
H at XX0R TRICKS TO YOU! $1 CLAIMS TO BE A BZIP2 FILE BUT IS A 
$FILETYPE!!!!!!!!1111111111oneoneone";
                                           fi
                                       else echo "No bunzip2 available"; 
fi ;
                                     fi ;;




-- 
Christos Ricudis				ricudis at itc.auth.gr
Systems Administrator				+30-2310-998656
IT Support Center
Aristotle University of Thessaloniki, GREECE




More information about the Linux-greek-users mailing list