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

19990909: generating gif files from cron



Steve,

When you run from cron you don't have the benefit of your entire
terminal set of environmental variables. 

Specifically, you probably don't have the DISPLAY environmental variable
set like you would in your login session- so the gif driver won't
be able to connect to your X display- whcich you need to have
open and allowing the cron user to connect to it. You also should
source the Gemenviron  file from your script to specifically
define all those gempak environmental variables that you
have set in your normal interactive environment.

Steve Chiswell
Unidata User Support
address@hidden


On Wed, 8 Sep 1999, Steven L. Mullen wrote:

> Steve,
> 
> I know that you have fielded this
> question before, but I can't seem to
> find a solution in the archives.
> 
> I am trying to generate from cron gif
> files to display on the Web. Sounds
> simple. The script below works
> fine when run interactively, but
> nothing is produced when run
> from cron. The script makes it
> to just before I try to execute
> snprof when run from cron (note
> all of the mail mullen < $LOGFILE).
> What do I need to do to come up
> to speed here? I am running on
> an SGI.
> 
> Thanks,
> Steve
> 
> #!/bin/csh
> ########################################################
> # Script for plotting today's and yesterday's RAOB for input stn
> #
> # Can be run from cron....some frickin day HOPEFULLY
> # Invoke with 2 argument: stn (3 letter id); hh for UTC
> #
> #
> # Log:
> # S. Mullen/HackUnixNovice 9-99
> ########################################################
> #
> # cd to proper directory
> *
> cd /cuser/mullen/html/gem
> #
> # Set up local variables
> #
> # DATA_DIR=GEMPAK gridded data directory;
> # LOGFILE=file to catch GEMPAK program output
> #
> setenv LOGFILE /cuser/mullen/html/gem/skewt.out
> setenv DATA_DIR /n4/data/gem/upperair
> #
> # Remove last hour's log file
> #
> /bin/rm -f $LOGFILE
> #
> # source the 5.2 environment variables
> #
> #source ~gempak51/52/Gemenviron
> #
> # Define current date
> #
> set yy=`date -u +%y`
> set mm=`date -u +%m`
> set dd=`date -u +%d`
> set date=${yy}${mm}${dd}
> set stn = '@'${1}
> set stnl = ${1}
> set hour=${2}
> echo $date $stn $stnl $hour >> $LOGFILE
> #
> # This section of the script computes julian day from
> # an input YYMMDD ${date}.
> # Result is stored in $OUTJULIAN
> 
> #@ inyear = ${date}
> #@ yr = $inyear
> #@ yr /= 10000
> #@ mo = $inyear - $yr * 10000
> #@ mo /= 100
> #@ dy = $inyear - $yr * 10000
> #@ dy = $dy - $mo * 100
> 
> set yr = ${yy}
> set mo = ${mm}
> set dy = ${dd}
> 
> echo $yr $mo $dy >> $LOGFILE
> 
> # non leap years
> set ndyyr = 365
> echo "ndyyr=" $ndyyr >> $LOGFILE
> set ndymo = ( 31 28 31  30  31  30  31  31  30  31  30  31)
> set julday = (31 59 90 120 151 181 212 243 273 304 334 365)
> # leap years
> if( $yr % 4 == 0) then
> set ndyyr = 366
> set ndymo = ( 31 29 31  30  31  30  31  31  30  31  30  31)
> set julday = (31 60 91 121 152 182 213 244 274 305 335 366)
> endif
> echo "ndyyr=" $ndyyr >> $LOGFILE
> 
> # find the julian day, store in $rday
>  if($mo != 1 ) then
>  @ ii = $mo - 1
>  @ rday = $julday[$ii] + $dy
>  else
>  @ rday = $dy
>  endif
> # end of julian day section
> echo $rday >> $LOGFILE
> 
> set datey = ${rday}
> @ datey -= 1
> echo "datey=" $datey >> $LOGFILE
> 
> #
> # This part of script computes YYMMDD from
> # an input year ${yy} and julian day ${datey}
> # Result is stored in $OUTDATE
> 
> # input mmdd for leap years
> set jday = ( 0101 0102 0103 0104 0105 0106 0107 0108 0109 0110 \
>              0111 0112 0113 0114 0115 0116 0117 0118 0119 0120 \
>              0121 0122 0123 0124 0125 0126 0127 0128 0129 0130 0131 \
>              0201 0202 0203 0204 0205 0206 0207 0208 0209 0210 \
>              0211 0212 0213 0214 0215 0216 0217 0218 0219 0220 \
>              0221 0222 0223 0224 0225 0226 0227 0228 0229  \
>              0301 0302 0303 0304 0305 0306 0307 0308 0309 0310 \
>              0311 0312 0313 0314 0315 0316 0317 0318 0319 0320 \
>              0321 0322 0323 0324 0325 0326 0327 0328 0329 0330 0331 \
>              0401 0402 0403 0404 0405 0406 0407 0408 0409 0410 \
>              0411 0412 0413 0414 0415 0416 0417 0418 0419 0420 \
>              0421 0422 0423 0424 0425 0426 0427 0428 0429 0430 \
>              0501 0502 0503 0504 0505 0506 0507 0508 0509 0510 \
>              0511 0512 0513 0514 0515 0516 0517 0518 0519 0520 \
>              0521 0522 0523 0524 0525 0526 0527 0528 0529 0530 0531 \
>              0601 0602 0603 0604 0605 0606 0607 0608 0609 0610 \
>              0611 0612 0613 0614 0615 0616 0617 0618 0619 0620 \
>              0621 0622 0623 0624 0625 0626 0627 0628 0629 0630 \
>              0701 0702 0703 0704 0705 0706 0707 0708 0709 0710 \
>              0711 0712 0713 0714 0715 0716 0717 0718 0719 0720 \
>              0721 0722 0723 0724 0725 0726 0727 0728 0729 0730 0731 \
>              0801 0802 0803 0804 0805 0806 0807 0808 0809 0810 \
>              0811 0812 0813 0814 0815 0816 0817 0818 0819 0820 \
>              0821 0822 0823 0824 0825 0826 0827 0828 0829 0830 0831 \
>              0901 0902 0903 0904 0905 0906 0907 0908 0909 0910 \
>              0911 0912 0913 0914 0915 0916 0917 0918 0919 0920 \
>              0921 0922 0923 0924 0925 0926 0927 0928 0929 0930 \
>              1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 \
>              1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 \
>              1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 \
>              1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 \
>              1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 \
>              1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 \
>              1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 \
>              1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 \
>              1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 )
> 
> @ inyear = ${yy}
> @ injday = ${datey}
> @ i = $injday
> # non leap years correction
> if( $inyear % 4 != 0 && $injday > 59) then
> @ i = $injday + 1
> endif
> set datey = ${inyear}${jday[$i]}
> #end of YYMMDD section of script
> 
> echo "datey=" $datey >> $LOGFILE
> mail mullen < $LOGFILE
> #
> #
> # Set some variables for SNPROF run
> #
> set grid=${DATA_DIR}/${date}_upa.gem
> set gridy=${DATA_DIR}/${datey}_upa.gem
> echo $grid $gridy >> $LOGFILE
> if( -e  /cuser/mullen/html/gem/gifs/skewt/${hour}_${stnl}.gif ) then
> /bin/rm /cuser/mullen/html/gem/gifs/skewt/${hour}_${stnl}.gif
> endif
> mail mullen < $LOGFILE
> #
> # Run SNPROF
> #
> $GEMEXE/snprof << EOF1  >> $LOGFILE
> \$RESPOND = y
> restore /cuser/mullen/html/gem/parm.snprof.skewt
> AREA=${stn}
> SNFILE=${gridy}
> DATTIM=${datey}/${hour}
> STNCOL=6
> line=6;6/1;5/3
> wind=bk6/1/2/112
> winpos=2
> DEVICE=gf|/cuser/mullen/html/gem/gifs/skewt/${hour}_${stnl}.gif|
> list
> run
> 
> SNFILE=${grid}
> DATTIM=${date}/${hour}
> STNCOL=2
> line=2;2/1;5/3
> wind=bk2/1/2/112
> winpos=1
> mixrln=0
> thtaln=0
> thteln=0
> clear=n
> DEVICE=gf|/cuser/mullen/html/gem/gifs/skewt/${hour}_${stnl}.gif|
> list
> run
> 
> exit
> EOF1
> #
> # Run GPEND to clean up
> #
> $GEMEXE/gpend
> #
> #xv gifs/skewt/${hour}_${stnl}.gif
> echo 'skewt.sh complete' >> $LOGFILE
> mail mullen < $LOGFILE
> exit
> 
> --
> -------------------------------------------------------
>      {}               Steven L. Mullen
>      {} {}            Dept. of Atmospheric Sciences
>   {} {} {}            University of Arizona
>   {} {} {}            1118 E. 4th St.
>    {}{}{}             PO Box 210081
>      {}               Tucson, Arizona 85721-0081
>      {}               Tel:(520) 621-6842
>      {}               Fax:(520) 621-6833
>      {}               Email: address@hidden
> -------------------------------------------------------
> 
> 
>