home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2536 < prev    next >
Encoding:
Text File  |  1992-11-17  |  4.8 KB  |  172 lines

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!news.u.washington.edu!milton.u.washington.edu!fhl
  3. From: fhl@milton.u.washington.edu (Dean Pentcheff)
  4. Subject: Re: NEED INFO ON WEATHER MAP SCRIPT/FPT ADDRESS (script enclosed)
  5. Message-ID: <1992Nov17.051212.25093@u.washington.edu>
  6. Followup-To: alt.sources
  7. Sender: Dean Pentcheff
  8. Reply-To: dean2@tbone.biol.scarolina.edu (Dean Pentcheff) 
  9. Organization: Department of Biology, University of South Carolina, Columbia
  10. References: <1992Nov16.183945.4294@clpd.kodak.com>
  11. Date: Tue, 17 Nov 1992 05:12:12 GMT
  12. Lines: 158
  13.  
  14. kirkpatr@thyroid.serum.kodak.com (Dan Kirkpatrick (x37370)) writes:
  15. >Could someone help point me in the direction of the weathermap 
  16. >scripts or what FTP address I can connect to get the pics?
  17.  
  18. The following script should do the job.  Note that its details assume
  19. that you're running under X Windows and have a specific package for
  20. displaying the GIF images - change as needed.
  21.  
  22. -Dean
  23. --
  24. Dean Pentcheff  (Internet: dean2@tbone.biol.scarolina.edu) (803) 777-8998
  25. Department of Biology, University of South Carolina, Columbia SC 29205
  26.  
  27. ====== Cut here (note - this is the script itself, not a shar file) =====
  28. #!/bin/csh
  29. # N. Dean Pentcheff  (dean2@tbone.biol.scarolina.edu)
  30. # 8/92
  31. #
  32. # Retrieve and display the diagrammatic weather map and visible and IR
  33. # weather satellite photos from a server machine.
  34. #
  35. # Requires the xview/xloadimage/xsetbg program, available from X contrib
  36. # sites.
  37. #
  38. # A potential weakness is the check for whether X is running.  I have
  39. # no idea if this will work as a general solution.  Try something
  40. # better if you can come up with it.
  41. #
  42. # Probably behaves poorly if the server is dead.
  43. #
  44.  
  45. unalias *
  46.  
  47. set wxhost = vmd.cso.uiuc.edu
  48. set wxdir  = wx
  49. set visible = CV
  50. set infrared = CI
  51. set map = SA
  52. set mapkey = WXKEY.GIF
  53. set localmapkey = /usr/local/lib/$mapkey
  54. set localname = $user@$HOST
  55. set pid = $$
  56. set tmpfile = $pid.tmp
  57. set tmpdir = /tmp
  58. set debug = 0
  59. set refresh = 0
  60. set show = 1
  61. set prog = $0
  62. set prog = $prog:t
  63.  
  64. # Parse arguments
  65. foreach arg ( $* )
  66.     switch ( $arg )
  67.         case "-d":    # debug mode
  68.             set debug = 1
  69.             breaksw
  70.         case "-s":    # don't display images
  71.             set show = 0
  72.             breaksw
  73.         case "-r":    # just refresh already-fetched images
  74.             set refresh = 1
  75.             breaksw
  76.         default:
  77.             echo Usage: $prog \[-d\] \[-s\] \[-r\]
  78.             echo "  -d  Debug mode"
  79.             echo "  -s  Don't show images"
  80.             echo "  -r  Refresh already-fetched images"
  81.             exit
  82.             breaksw
  83.     endsw
  84. end
  85.  
  86. # Is X running at all?  If not, don't display
  87. if ( `ps -awww | grep ' X ' | wc -l` < 1 ) then
  88.     if ( $debug == 1 ) Echo $$ X not running, no display
  89.     set show = 0
  90. endif
  91.  
  92. # If we're going to try fetching, do it
  93. if ( $refresh == 0 ) then
  94.     # Fetch and optionally display the images
  95.     if ( $debug == 1 ) echo -n $$ Beginning fetch: GMT time:
  96.     if ( $debug == 1 ) date -u
  97.     
  98.     # fetch the directory entries from the server
  99.     if ( $debug == 1 ) echo $$ Getting remote dir into $tmpdir/$tmpfile
  100.     ftp -n $wxhost >&! /dev/null <<END_OF_FTP_SCRIPT_1
  101.         user anonymous $localname
  102.         cd $wxdir
  103.         lcd $tmpdir
  104.         ls . $tmpfile
  105.         bye
  106. END_OF_FTP_SCRIPT_1
  107.     
  108.     # Figure out what to get
  109.     set getvisible  = "get `grep $visible  $tmpdir/$tmpfile | tail -1`"
  110.     set getinfrared = "get `grep $infrared $tmpdir/$tmpfile | tail -1`"
  111.     set getmap      = "get `grep $map      $tmpdir/$tmpfile | tail -1`"
  112.     if ( -e $localmapkey  ||  -e $tmpdir/$mapkey ) then
  113.         if ( $debug == 1 ) echo Local key, not refetched
  114.         set getmapkey = ""
  115.     else
  116.         if ( $debug == 1 ) echo No local key, will fetch that too
  117.         set getmapkey = "get $mapkey"
  118.     endif
  119.         
  120.     # Get files from server
  121.     if ( $debug == 1 ) echo $$ Fetching files:
  122.     if ( $debug == 1 ) echo $$ $getvisible
  123.     if ( $debug == 1 ) echo $$ $getinfrared
  124.     if ( $debug == 1 ) echo $$ $getmap
  125.     if ( $debug == 1 ) echo $$ $getmapkey
  126.     ftp -n $wxhost >&! /dev/null <<END_OF_FTP_SCRIPT_2
  127.         user anonymous $localname
  128.         binary
  129.         cd $wxdir
  130.         lcd $tmpdir
  131.         $getvisible
  132.         $getinfrared
  133.         $getmap
  134.         $getmapkey
  135.         bye
  136. END_OF_FTP_SCRIPT_2
  137. else
  138.     if ( $debug == 1 ) echo $$ No fetching, just refreshing
  139. endif
  140.  
  141. # If appropriate, display files
  142. if ( $show == 1 ) then
  143.     if ( $debug == 1 ) echo $$ Files fetched, displaying...
  144.     cd $tmpdir
  145.     if ( -e $localmapkey ) then
  146.         if ( $debug == 1 ) echo $$ Local key: $localmapkey
  147.         xloadimage -fit -fork $localmapkey
  148.     else
  149.         if ( $debug == 1 ) echo $$ Fetched key: $mapkey
  150.         xloadimage -fit -fork $mapkey
  151.     endif
  152.     xloadimage -fit -fork `ls -t SA??????.GIF | head -1`
  153.     sleep 6
  154.     xloadimage -fit -fork `ls -t CV??????.GIF | head -1`
  155.     xloadimage -fit -fork `ls -t CI??????.GIF | head -1`
  156. else
  157.     if ( $debug == 1 ) echo $$ Files fetched, not displayed
  158. endif
  159.  
  160. # Clean up tmp file
  161. if ( $debug == 1 ) then
  162.     echo $$ If not debug, would rm -f $tmpdir/$tmpfile
  163. else
  164.     rm -f $tmpdir/$tmpfile
  165. endif
  166.  
  167. if ( $debug == 1 ) echo $$ Done
  168.  
  169. exit
  170.  
  171. # End Of Script
  172.