[Novalug] Sample shell code...

geoff mcnamara geoffm@companionway.net
Thu Feb 22 18:08:23 EST 2007


Try changing the "shebang" line to #/bin/bash
Some distos link /bin/sh to a bask like shell - some use a more 
rudimentary sheel (without the capability to play the variable 
substitution game as seen in the line:
  PROCESS=${PREPROCESS//\/0}

-geoff


Beartooth wrote:
> On Thu, 22 Feb 2007, Megan Larko wrote:
>
>> Beartooth and Company,
>>
>> I tried the sample shell script posted to NoVALUG List.  It worked 
>> for me exactly following the instructions of the kind person who 
>> posted it (I deleted the original post so I cannot attribute correctly).
>>
>> Beartooth, I had no problem with line 10 and/or any ] issues.
>>
>> I am re-posting it here for others and a comparison check.
>>
>> #!/bin/sh #
>>
>> LAST=none
>> for PREPROCESS in $(ps -e | awk '{print $4}') ; do
>> PROCESS=${PREPROCESS//\/0}
>> MAN=$(man -f ${PROCESS})
>> TEST_MAN=${MAN//nothing appropriate}
>> if [ "${#MAN}" = "${#TEST_MAN}" -a "${PROCESS}" != "${LAST}" ] ; then
>>   LAST=${PROCESS}
>>   echo ${MAN}
>>   echo
>> fi
>> done | less
>>
>     Well, since I run my email and my user prompt on different tabs of 
> the same terminal, it was pretty straightforward to compare. I suppose 
> there must be a difference between what I have and what I see on 
> Novalug (without all the angle brackets along the left margin) -- but 
> I sure don't see it.
>
>     And I still get a screenful of complaints about an orphan square 
> bracket in "line 10" ...
>
>>
>> It does a nice, quick job of looking at processing running on the 
>> system and then returning a brief description from the man page of 
>> what that process is designed to do.  FYI, a "q" exits the job when 
>> it has finished its listing (one will see a colon on a line by itself).
>
>     <sigh> ... and someone objected to my labelling (some of) my 
> questions "Very Dumb" ...
>




More information about the Novalug mailing list