From: yanoff@csd4.csd.uwm.edu (Scott A. Yanoff)
Subject: Weather Map scripts found-Thanx!
Originator: yanoff@csd4.csd.uwm.edu
Organization: University of Wisconsin - Milwaukee, WI
Date: Fri, 24 Jul 1992 14:21:53 GMT


Thanx to all those who sent me their "get weather gif" scripts.
I got a variety of them, some in Perl and some in Csh.
Not all of them worked for me, but at least 2 did.

I made a shar of all the scripts I got, and I have decided to post them for
you below:


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  wx1 wx2 tippy weathergif wxftp wxget wxget.doc
# Wrapped by yanoff@csd4.csd.uwm.edu on Fri Jul 24 09:19:08 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'wx1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wx1'\"
else
echo shar: Extracting \"'wx1'\" \(2684 characters\)
sed "s/^X//" >'wx1' <<'END_OF_FILE'
X
X#!/usr/bin/perl
X#Copyright Scott D. Yelich  July 14, 1992                   ALL RIGHTS RESERVED
X
Xpackage WMap;
X
X$date = 'Tue Jul 21 20:04:48 MDT 1992';
X$title = 'WMap';
X$author = 'Scott D. Yelich';
X$version = '1.00';
X$copyright = 'Copyright Scott D. Yelich July 21, 1992.  ALL RIGHTS RESERVED';
X
X#------------------------------------------------------------------------------
X
Xsub Display {					#
X  if ( $ENV{'DISPLAY'} ) {			#
X    system("$DISPLAY $LIB/$_[$[] 2> $NULL &");	# 
X  } else {					# 
X    print STDOUT "No DISPLAY... No image...\n";	# 
X  }						# 
X}						# 
X
X#------------------------------------------------------------------------------
X
Xsub Forecast {					# 
X  system("$Forecast $Location");		# 
X}						# 
X
X#------------------------------------------------------------------------------
X
Xsub GetWMap {					# 
X  local($MapName) = @_;				# 
X  if ( ! -e "$LIB/$MapName" && $ENV{'DISPLAY'}){# 
X    print STDOUT "Retrieving image...\n";	# 
X    close(O);					# 
X    open(O,"|$FTP $WMapFTPHostAddr >>$NULL");	# BEGIN FTP SESSION
X    print O "anonymous\n";			#  Login ID.
X  #  print O "anonymous\n"; 			#  What?  NO PASSOWRD? Uh, ok!
X    print O "binary\n";				#  Transfer image mode.  (haha)
X    print O "cd wx\n";				#  CD to proper DIR.
X    print O "lcd $LIB\n";			#  LCD to proper DIR.
X    print O "get $MapName\n";			#  Transfer image.
X    print O "quit\n";				# END FTP SESSION
X    close(O);					# 
X  }						# 
X  $MapName;					# 
X}						# 
X
X#------------------------------------------------------------------------------
X
Xsub WMapName {					# 
X  local($sec,$min,$hour,			# 
X        $mday,$mon,$year,			# 
X        $wday,$yday,$isdst) = gmtime(time);	# 
X  $mon++;					# 
X  $mon = "0$mon" if ($mon < 10);		# 
X  $mday = "0$mday" if ($mday < 10);		# 
X  $hour--;
X  $hour = "0$hour" if ($hour < 10);		#  
X  "SA$mon$mday$hour.GIF";			# 
X}						# 
X
X#------------------------------------------------------------------------------
X
Xsub Initialize {				#
X  $TRUE = '1';					# '1' = TRUE  = '1'
X  $FALSE = '';					# ''  = FALSE =  ''
X  $NULL = '/dev/null';				# 
X  $FTP = '/usr/ucb/ftp';			# 
X  $DISPLAY = '/net/packages/X/bin/xv';		# 
X  $Forecast = "/usr/local/bin/forecast";	# City code for forecast.
X  $Location = "ABQ";				# City code for forecast.
X  $WMapFTPHostName = 'vwd.cso.uiuc.edu';	# 
X  $WMapFTPHostAddr = '128.174.5.98';		# 
X  $LIB = '/usr/local/lib/wmap';			# 
X}						# Exit.
X
X#------------------------------------------------------------------------------
X
Xsub WXMap {					# 
X  &Initialize();				# 
X  &Forecast();					#
X  &Display(&GetWMap(&WMapName()));		# 
X}						# 
X
X#------------------------------------------------------------------------------
X
X&WXMap();					# 
X
END_OF_FILE
if test 2684 -ne `wc -c <'wx1'`; then
    echo shar: \"'wx1'\" unpacked with wrong size!
fi
chmod +x 'wx1'
# end of 'wx1'
fi
if test -f 'wx2' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wx2'\"
else
echo shar: Extracting \"'wx2'\" \(723 characters\)
sed "s/^X//" >'wx2' <<'END_OF_FILE'
X#!/bin/sh
X
XKEY=0
XONROOT="-onroot -fullscreen -border black"
X
Xwhile [ $# -ne 0 ]; do
X	arg=$1; shift
X	case ${arg} in
X		-key)
X			KEY=1
X			;;
X		*)
X			echo "Usage: $0 [-key]"
X			;;
X	esac
Xdone
X
Xif [ ${KEY} -eq 1 ]; then
X	files="wxkey.gif" ;
Xelse
X	files=`date -u +"%m %d %H" | awk '{
X		for (i = 0; i < 5; i++) {
X  k = $3 - i + 5; j = $2
X  if (k > 23) {k -= 24; j += 1}
X			printf "SA%s%02d%02d.GIF\n", $1, j, k;
X  }
X	}'`
Xfi
X
Xfor file in ${files}; do
X	ftp -i -n vmd.cso.uiuc.edu <<EOF
Xuser anonymous ${USER}@`hostname`
Xbinary
Xcd wx
Xget ${file} /tmp/wxmap.gif.$$
Xquit
XEOF
X
X	if [ -f /tmp/wxmap.gif.$$ ]; then
X		/usr/local/bin/xloadimage ${ONROOT} -quiet /tmp/wxmap.gif.$$  -display unix:0
X		rm -f /tmp/wxmap.gif.$$
X		break;
X	fi
Xdone
X
END_OF_FILE
if test 723 -ne `wc -c <'wx2'`; then
    echo shar: \"'wx2'\" unpacked with wrong size!
fi
chmod +x 'wx2'
# end of 'wx2'
fi
if test -f 'tippy' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tippy'\"
else
echo shar: Extracting \"'tippy'\" \(974 characters\)
sed "s/^X//" >'tippy' <<'END_OF_FILE'
X#! /bin/csh
X#
X# script to set up the wxftp.fil file so that wxftp knows weather to
X# get a directory listing (tippy 1 > wxftp.fil) or to get the image
X# files (tippy 0 > wxftp.fil)
X#
X# James N. Stricherz
X# stricher@masig3.ocean.fsu.edu
X#
Xset change="cd wx"
Xset adios="bye"
Xset users="user anonymous yanoff@convex.csd.uwm.edu"
Xif ( $1 == 0 ) then
X   set binar="binary"
X   set testci=`grep CI wxftp.res | tail -1`
X   set testcv=`grep CV wxftp.res | tail -1`
X   set testsa=`grep SA wxftp.res | tail -1`
X   set getci="get $testci[1].$testci[2]"
X   set getcv="get $testcv[1].$testcv[2]"
X   set getsa="get $testsa[1].$testsa[2]"
X#
X#  use the following set if you get an subscript error.
X#
X#   set getci="get $testci"
X#   set getcv="get $testcv"
X#   set getsa="get $testsa"
X   echo $users
X   echo $binar
X   echo $change
X#  echo $getci
X#  echo $getcv
X   echo $getsa
X   echo $adios 
X
Xelse
X   set comman="ls"
X   echo $users
X   echo $change
X   echo $comman
X   echo $adios 
X
Xendif
Xexit
END_OF_FILE
if test 974 -ne `wc -c <'tippy'`; then
    echo shar: \"'tippy'\" unpacked with wrong size!
fi
chmod +x 'tippy'
# end of 'tippy'
fi
if test -f 'weathergif' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'weathergif'\"
else
echo shar: Extracting \"'weathergif'\" \(412 characters\)
sed "s/^X//" >'weathergif' <<'END_OF_FILE'
X#! /bin/sh
X
Xhost=vmd.cso.uiuc.edu
Xdir=wx
Xtmp=/tmp/sa$$
Xtrap "rm -f $tmp" 1 2 3 15
X
Xftp -niv $host >$tmp <<!
Xuser anonymous
Xcd $dir
Xdir SA*.GIF
Xquit
X!
X
Xfile=`awk '$2=="GIF" {f=$1} END {print f".GIF"}' $tmp`
Xlfile=`echo $file | tr A-Z a-z`
X
Xif [ -f $lfile ] ; then
X	echo $lfile: already exists
X	exit 1
Xfi
X
Xftp -ni $host <<!
Xuser anonymous
Xcd $dir
Xbinary
Xget $file $lfile
Xquit
X!
X
Xecho $lfile: copied
X
Xrm $tmp
Xexit
X
END_OF_FILE
if test 412 -ne `wc -c <'weathergif'`; then
    echo shar: \"'weathergif'\" unpacked with wrong size!
fi
chmod +x 'weathergif'
# end of 'weathergif'
fi
if test -f 'wxftp' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wxftp'\"
else
echo shar: Extracting \"'wxftp'\" \(1283 characters\)
sed "s/^X//" >'wxftp' <<'END_OF_FILE'
X#!/bin/sh
X#
X#	Note: I didn't write this, I have no idea where *I* got it
X#	from, but it works for me. Part of the WeatherGif retrieval
X#	package.
X#
X# Shell script to try repeatedly to get files via ftp from the host named
X# below. The host is repeatedly polled until the session is successfully
X# completed.
X# This is the site we're ftp'ing to. Can be either symbolic or numeric.
X#
Xhost=vmd.cso.uiuc.edu
X#
X# Define the input, result and error files.
X#
Xin=$0.fil  #$0 is the name of this script file
Xout=$0.res # If you call it getgif, then these files will be
Xerr=$0.err # getgif.fil, getgif.res and getgif.err
X#
X# How long to sleep between subsequent tries (in seconds):
X#
Xtime=3600	# An hour
Xecho "Starting to get files from $host." > $out
X#
X# Try to make connection w/out error loop first time
X# Initialize the error message file so we start the loop:
X#
Xecho "Trying to reach $host at time:" >> $out
Xdate >> $out
Xftp -n -v $host < $in >> $out 2> $err
X#
X# MAIN LOOP: If error file isn't empty, we sleep for an hour and try again.
X#
Xwhile test -s $err
Xdo
X  echo "Cannot connect now, will try again in $time seconds." >> $out
X  sleep $time
X  echo "Trying to reach $host at time:" >> $out
X  date >> $out
X  ftp $host < $in >> $out 2> $err
Xdone
Xecho "File transfer successful!" >> $out
END_OF_FILE
if test 1283 -ne `wc -c <'wxftp'`; then
    echo shar: \"'wxftp'\" unpacked with wrong size!
fi
chmod +x 'wxftp'
# end of 'wxftp'
fi
if test -f 'wxget' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wxget'\"
else
echo shar: Extracting \"'wxget'\" \(534 characters\)
sed "s/^X//" >'wxget' <<'END_OF_FILE'
X#! /bin/csh
X#
X# csh script by James N. Stricherz - stricher@masig3.ocean.fsu.edu
X#
X# 29 Jan 1991 - runs sub-Scripts to automajically fetch the latest 
X
X#You can anonymous FTP /weather/get_gifs from ncardata.ucar.edu.
X
X# satellite imagery from vmd.cso.uiuc.edu
X#
X# get the file list from vmd (tippy=1)
X#
X
Xtippy 1 > wxftp.fil
X
Xecho Starting first ftp job
X
Xwxftp
X
X# 
X
X# ok, now get the new files (tippy=0)
X#
X
Xtippy 0 > wxftp.fil
X
Xecho Starting second ftp job
X
Xwxftp
X
X#
X# uncomment the next line to display the pics as well
X#
X#wxgif
Xexit
END_OF_FILE
if test 534 -ne `wc -c <'wxget'`; then
    echo shar: \"'wxget'\" unpacked with wrong size!
fi
chmod +x 'wxget'
# end of 'wxget'
fi
if test -f 'wxget.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'wxget.doc'\"
else
echo shar: Extracting \"'wxget.doc'\" \(1208 characters\)
sed "s/^X//" >'wxget.doc' <<'END_OF_FILE'
XThis is a set of scripts that will auotmajically retrieve the latest
Xweather images on vmd.cso.uiuc.edu. Usage is easy:
X
X% wxget 
X
X[wait]
X
XYou will get some feed back concerning the startup of the ftp script
Xeach time it is called (once to get the latest file list, the second
Xtime to get the files). 
X
X
XThe heart of this majic is the script tippy. It is also it's weakest
Xpoint. Works wonderfully under zsh, but most people probably don't 
X
Xhave it. So I converted it to csh, but I discovered that two different
Xcsh's didn't run it the same way. :( I left it the way it runs on
Xour SGI 4d. If you have problems with a subscript error, then remove
Xor comment out the lines:
X
X   set getci="get $testci[1].$testci[2]"
X   set getcv="get $testcv[1].$testcv[2]"
X   set getsa="get $testsa[1].$testsa[2]"
X
XThe replacements will have to be uncommented. Another thing in
X_tippy_ that needs replacement is the string: username@machine.
XTheoretically speaking, this should reflect your email address.
X
XOther than that, Enjoy! This *is* a freebie - you get what you pay
Xfor, and I *will* not be held responsible for *any* damage that using
Xthis may cause.
X
X29 Jan 1992
X
XJames N. Stricherz
Xstricher@masig3.ocean.fsu.edu
X
END_OF_FILE
if test 1208 -ne `wc -c <'wxget.doc'`; then
    echo shar: \"'wxget.doc'\" unpacked with wrong size!
fi
# end of 'wxget.doc'
fi
echo shar: End of shell archive.
exit 0
-- 
 _/\ _ !\ _         @           Milwaukee, WI - A Great Place by a Great Lake
!  _! !! ! !_  ~~  @ ~  ~~         
! ! ! !! ! ! !~~__=||_~ ~~~          *** Computing Services Division ***
! ! ! _! ! ~~~ ~\____/  ~~~ yanoff@csd4.csd.uwm.edu   yanoff@elvis.csd.uwm.edu
Newsgroups: alt.internet.services