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

20051106: Shell scripts under FC 4 have trouble executing



>From: Gilbert Sebenste <address@hidden>
>Organization: NIU
>Keywords: 200511060731.jA67VL7s020450 LDM pqact PIPE script

Hi Gilbert,

re:
>On Sun, 6 Nov 2005, Gilbert Sebenste wrote:
>> OK. This has me stumped. If you can help, I'd greatly appreciate it.
>>
>> I didn't get watches and warnings emailed to me today from weather3, now 
>> running Fedora Core 4. As an example, this line:
>>
>> WMO     ^WUUS53 (KLOT|KDVN) ([0-3][0-9])([0-2][0-9])
>>        PIPE    -close -strip /home/ldm/warnscripts/tstormwarning
>>
>> And this script:
>>
>> #
>> PATH=/usr/local/bin:/bin:/usr/sbin:/etc:/usr/local/etc:/usr/bin:/bin
>> LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
>> UDRESPATH=/usr/local/etc
>> export PATH LD_LIBRARY_PATH UDRESPATH
>> dir=/tmp/
>> /bin/cat <&0 > ${dir}$1.$$
>> sleep 1
>>
>> if [ `/bin/grep -- "KLOT" ${dir}$1.$$ | /usr/bin/wc -l` -gt 0 ]
>> then
>> if [ `/bin/grep -- "197-" ${dir}$1.$$ | /usr/bin/wc -l` -gt 0 ]
>> then
>> if [ `/bin/grep -- "WILL COUNT" ${dir}$1.$$ | /usr/bin/wc -l` -gt 0 ]
>> then
>> /bin/cat ${dir}$1.$$ | /bin/mail -s "ALERT: SEVERE THUNDERSTORM WARNING--WIL
> L 
>> COUNTY" will
>> fi
>> fi
>> fi
>>
>> /bin/rm -f ${dir}$1.$$
>
>Note: if I remove the "$1" after each {dir} above, the right file name 
>is sent to the /tmp directory (like .23411), but it doesn't get removed, 
>which it should, if I remove EVERY "$1" in the script above.

Your script references the first passed parameter to the script, $1,
but you are not passing any parameters to your script!  $1 is,
therefore, blank.  Did you mean for your pqact.conf action to be:

WMO     ^WUUS53 (KLOT|KDVN) ([0-3][0-9])([0-2][0-9])
        PIPE    -close -strip /home/ldm/warnscripts/tstormwarning \1\2\3

>Another FC4 "GOTCHA!".

I don't think that your problem has anything to do with FC4.  Rather, I
think your script is assuming that something is available when it is
not.  Because $1 is blank, the resulting file you are creating is
hidden (name begins with '.').

I recommend that you capture a product to use for testing and then
running your script by hand to troubleshoot it.

For instance, save a severe thunderstorm warning as test.warn and
then run:

cat test.warn | /home/ldm/warnscripts/tstormwarning

Add echoing of the values of the various pieces you are using:

 ...
dir=/tmp/
echo "first passed parameter = >$1<"
echo "process ID = $$"
/bin/cat <&0 > ${dir}$1.$$
sleep 1
etc

I just did this on my FC4 machine, and get what I expected:

[mcidas@zeldagillroy tmp]$ cat xxx | ./tstormwarning
first passed parameter = ><
process ID = 2649

Cheers,

Tom
--
NOTE: All email exchanges with Unidata User Support are recorded in the
Unidata inquiry tracking system and then made publicly available
through the web.  If you do not want to have your interactions made
available in this way, you must let us know in each email you send to us.