WESTERN REGION TECHNICAL ATTACHMENT

NO. 96-24

SEPTEMBER 24, 1996

CURRENT SATELLITE IMAGERY FOR HOMEPAGES

Elisa Brewerton - WRH/SSD, Salt Lake City, UT

Introduction

Displaying current satellite images on the homepage can be a benefit to the public, especially those interested in aviation weather, fire weather, marine weather, or flash flood situations. This Technical Attachment (TA) will give the information needed to make these products available on a homepage.

To display current satellite images on the homepage, three things are needed for a UNIX workstation: a csh (pronounced c-shell) script, a crontab file, and HTML code. The csh script FTPs (file transfer protocol) the proper files from RAMSDIS to the homepage directory. The crontab file executes the csh script at a specified time interval. The HTML code allows the images to be displayed on the world wide web.

This TA gives you the script, the instructions on how to create a crontab file, and the HTML code.

Script

The script is based on the getAREAfiles script, originally written by Ron Miller, SOO at NWSO Spokane. David Zaff NWSFO Salt Lake City modified the original script to perform the FTP desired. The script FTPs to RAMSDIS and then retrieves the latest gif satellite images. It then can FTP these files to the homepage.

The script is available via FTP from Nimbo.wrh.noaa.gov (title of the script: satellitescript, in the default directory: /users/http) or it may be copied from this TA. In any directory, save the script with a ".csh" extension.

The script requires some local information. The information to be added is indicated by a set of "<>" marks. Remove these marks when adding or changing the information, or giving user-names and passwords. The lines in the script beginning with "#" are comment lines. The comment lines include instruction on possible modifications to the script. There is one exception, the line "#!/bin/csh" is not a comment line, but is necessary for proper execution of the script. If the file names do not correlate with local RAMSDIS file names, then they must also be changed.

#Start of script
#!/bin/csh

set UNIX_GIFDIR=
set RAMSDIS_GIFDIR=mcidas/data 
set WEBPAGE_DIR=
set RAMSDIS_HOSTNAME=
set WEBPAGE_HOSTNAME=nimbo.wrh.noaa.gov 

# start ftp job and collect files from RAMSDIS
# if username and password are necessary for RAMSDIS, enter that 
# information where prompted, if not delete the entire line

ftp -nv $RAMSDIS_HOSTNAME << _EOF_
user    
binary
lcd $UNIX_GIFDIR
cd $RAMSDIS_GIFDIR
get ir4.gif
get vis1.gif
get wv8.gif
get vis4.gif
get visrad.gif
get irrad.gif
bye
_EOF_

# send the images to the Web page

ftp -nv $WEBPAGE_HOSTNAME << _EOF_
user  
cd $WEBPAGE_DIR
lcd $UNIX_GIFDIR
binary
put ir4.gif
put vis1.gif
put wv8.gif
put vis4.gif
put visrad.gif
put irrad.gif
bye
_EOF_

# copy new gif files to local httpd directory
# uncomment (by removing "#") the following line if wanted for use on intranet
#cp $GIFDIR/*gif //$WEBPAGE_DIR
#End of script

Crontab Files

In a UNIX environment, periodic execution is handled by the cron daemon. Cron starts when the system is booted and will remain running as long as the system is up. Cron reads crontab configuration file(s) that have a list of commands and command execution times.

If the script is called from a crontab file, the system will update the satellite images at specified intervals.

To set up crontab file:
Do not edit the actual crontab file. Follow these commands and the file will be set up for you.
1. Make sure a cronjob is not currently running by typing crontab -l. The message, "crontab: can't open your crontab file", should appear. If this message does not appear, contact your System Administrator before proceeding.
2. Open a text editor or use vi and create a file titled "cronfile".
3. In "cronfile", enter in a command line. (see below)
4. Save the file.
5. At a UNIX prompt, type crontab cronfile to start the cronjob.

Cronjob Command Line format is:
minute hour day month week command

Cronjob time specifications:
  Time field                              Range
 minute (minute of the hour)             0 to 59
 hour (hour of the day)                  0 to 2
 day (day of the month)                  1 to 3
 month (month of the year)               1 to 12
 week (day of the week)                  0 to 6 (0=Sun)

Each of the time fields can be entered as one of the following:
-an asterisk that will match anything
-a single integer (within the range) that will be a specific match
-more than one integer separated by commas that will match a list of values
-two integers separated by a dash that will match a range of values

For example:
  0,15,30,45  *  10-15  1,2,10,11,12  *  command
will execute command every fifteen minutes, every hour, every day of the week, for the tenth to the fifteenth, for the months January, February, October, November, and December.

Command is a sh command line to be executed. It can contain blanks and tabs. The command to execute this script would have the format:
/bin/csh /(directory_location)/(of_script)/(script_name).csh

Note: Every time this cronjob is executed, a message is mailed to the user.



Adding Images to Homepage



To add the images, link the image from an existing page or a new page with the command:
<a href="gif_file_name">Name_of_image</a>
or place the image on an existing page or new page with the command:
<img src="gif_file_name">.

On the Western Region homepage, the current satellite images are located in "Current Imagery".

Note: Real-time satellite imagery is a service to the public. So, when giving the Name_ of_image, be sure to denote which weather product it is associated with.

Conclusion

Displaying current satellite images on the homepage can be a benefit to the public, especially those interested in aviation weather, fire weather, marine weather, or flash flood situations. With the use of scripts and crontab files, real-time data are easily added to homepages.