NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.


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

[LDM #LIN-843313]: Question on manually inserting METARs into ldm.pq through a script



Gilbert,

> Got a question for you.
> 
> In case NOAAPort goes out, I want to insert METARs into the ldm queue so
> that GEMPAK can get them. The Aviation Weather Center (AWC) now has a
> fiber backup to get METARs in case NOAAport/AWIPS SBN goes down again.
> I have a script that kind of works...to grab them and insert them into the
> ldm.pq file.The first one runs flawlessly. The next ones do not:
> 
> ldm %/home/ldm/grabawcmetars2 > /dev/shm/awcmetars.txt
> pqinsert ERROR: open: /dev/shm/awcmetars.txt: No such file or directory
> pqinsert ERROR: open: /dev/shm/awcmetars.txt: No such file or directory
> pqinsert ERROR: open: /dev/shm/awcmetars.txt: No such file or directory
> pqinsert ERROR: open: /dev/shm/awcmetars.txt: No such file or directory
> 
> This is the script:
> 
> #!/bin/csh
> printf "\001\r\r\n000 \r\r\n"
> printf "SAUS80 KWBC `date --utc +%d%H%M`\r\r\n"
> printf "METAR\n"
> wget -o /dev/null -O - 
> 'http://adds.aviationweather.gov/metars/index.php?station_ids=@AL%20@AK%20@AZ%20@AR%20@CA%20@CO%20@CT%20@DE%20@FL%20@GA&chk_metars=on'|
>  grep FONT | sed -e 's/<\/FONT>/=/' -e 's/<[^>]*.//g' -e 's/$/\x0D\x0D/'
> printf "\r\r\n\003"
> pqinsert -q /home/ldm/data/ldm.pq -s 000 -f "IDS|DDPLUS" -p "SAUS80 KWBC 
> `date --utc +%d%H%M`" /tmp/awcmetars.txt
> sleep 1
> /bin/rm -f /tmp/awcmetars.txt

It looks like you're relying on the invocation of the script to create the file 
"/tmp/awcmetars.txt" via redirection of the standard output stream --- but the 
script itself also references that same file.  In general, that's not a good 
idea because it couples the invocation of the script with the scripts execution.

I think the rm(1) invocation in the script is removing the output file, 
/tmp/awcmetars.txt, and that the subsequent invocations of pqinsert(1) can't, 
therefore, find the file --- even though it still exists due to output 
redirection of the script invocation.

> #
> printf "\001\r\r\n001 \r\r\n"
> printf "SAUS80 KWBC `date --utc +%d%H%M`\r\r\n"
> printf "METAR\n"
> wget -o /dev/null -O - 
> 'http://adds.aviationweather.gov/metars/index.php?station_ids=@HI%20@ID%20@IL%20@IN%20@IA%20@KS%20@KY%20@LA%20@ME%20@MD&chk_metars=on'|
>  grep FONT | sed -e 's/<\/FONT>/=/' -e 's/<[^>]*.//g' -e 's/$/\x0D\x0D/'
> printf "\r\r\n\003"
> pqinsert -q /home/ldm/data/ldm.pq -s 000 -f "IDS|DDPLUS" -p "SAUS80 KWBC 
> `date --utc +%d%H%M`" /tmp/awcmetars.txt
> sleep 1
> /bin/rm -f /tmp/awcmetars.txt
> #
> printf "\002\r\r\n002 \r\r\n"
> printf "SAUS80 KWBC `date --utc +%d%H%M`\r\r\n"
> printf "METAR\n"
> wget -o /dev/null -O - 
> 'http://adds.aviationweather.gov/metars/index.php?station_ids=@MA%20@MI%20@MN%20@MS%20@MO%20@MT%20@NE%20@NV%20@NH%20@NJ&chk_metars=on'|
>  grep FONT | sed -e 's/<\/FONT>/=/' -e 's/<[^>]*.//g' -e 's/$/\x0D\x0D/'
> printf "\r\r\n\003"
> pqinsert -q /home/ldm/data/ldm.pq -s 000 -f "IDS|DDPLUS" -p "SAUS80 KWBC 
> `date --utc +%d%H%M`" /tmp/awcmetars.txt
> sleep 1
> /bin/rm -f /tmp/awcmetars.txt
> #
> printf "\004\r\r\n004 \r\r\n"
> printf "SAUS80 KWBC `date --utc +%d%H%M`\r\r\n"
> printf "METAR\n"
> wget -o /dev/null -O - 
> 'http://adds.aviationweather.gov/metars/index.php?station_ids=@NM%20@NY%20@NC%20@ND%20@OH%20@OK%20@OR%20@PA%20@RI%20@SC&chk_metars=on'|
>  grep FONT | sed -e 's/<\/FONT>/=/' -e 's/<[^>]*.//g' -e 's/$/\x0D\x0D/'
> printf "\r\r\n\003"
> pqinsert -q /home/ldm/data/ldm.pq -s 000 -f "IDS|DDPLUS" -p "SAUS80 KWBC 
> `date --utc +%d%H%M`" /tmp/awcmetars.txt
> sleep 1
> /bin/rm -f /tmp/awcmetars.txt
> #
> printf "\005\r\r\n005 \r\r\n"
> printf "SAUS80 KWBC `date --utc +%d%H%M`\r\r\n"
> printf "METAR\n"
> wget -o /dev/null -O - 
> 'http://adds.aviationweather.gov/metars/index.php?station_ids=@SD%20@TN%20@TX%20@UT%20@VT%20@VA%20@WA%20@WV%20@WI%20@WY&chk_metars=on'|
>  grep FONT | sed -e 's/<\/FONT>/=/' -e 's/<[^>]*.//g' -e 's/$/\x0D\x0D/'
> printf "\r\r\n\003"
> pqinsert -q /home/ldm/data/ldm.pq -s 000 -f "IDS|DDPLUS" -p "SAUS80 KWBC 
> `date --utc +%d%H%M`" /tmp/awcmetars.txt
> sleep 1
> /bin/rm -f /tmp/awcmetars.txt
> 
> Now, the first part executes just fine; states A-G's METARs get inserted.
> The second one and all the others do grab the METARs, but don't put them
> into the /tmp/awcmetars.txt file.
> 
> I don't know why. I could run 5 different scripts, but why, when I can do
> it all at once. Any idea of what I am doing wrong above?
> 
> Thanks!
> 
> *******************************************************************************
> Gilbert Sebenste                                                     ********
> (My opinions only!)                                                  ******
> Staff Meteorologist, Northern Illinois University                      ****
> E-mail: address@hidden                                  ***
> web: http://weather.admin.niu.edu                                      **
> *******************************************************************************


Regards,
Steve Emmerson

Ticket Details
===================
Ticket ID: LIN-843313
Department: Support LDM
Priority: Normal
Status: Closed