#! /bin/csh # Copyright (C) 2001 MBARI # Author: Kent Headley # MBARI provides this documentation and code "as is", with no warranty, # express or implied, of its quality or consistency. It is provided without # support and without obligation on the part of the Monterey Bay Aquarium # Research Institute to assist in its use, correction, modification, or # enhancement. This information should not be published or distributed to # third parties without specific written permission from MBARI. # getMooring - C Shell script to download data from OASIS Controller # and extract the data # # Must use full DOS path instead of symlink to /oasis since tclsh80 converts # UNIX ('/') paths to DOS ('\') paths # # Directories # set OASIS = /oasis set CFG = $OASIS/cfg set RAW = $OASIS/raw set BIN = $OASIS/bin set CAN = m2 set ERROR_DIR = $OASIS/$CAN/error # # General # set FILEBASE = `date +%Y%j` # Missing Records File set RCDFILE = $RAW/oasis.rcd # Download Logs (old & new) set DLLOG = "dlinfo" set OLDLOG = "dlinfo.log" set TRUE = 1 set FALSE = 0 set noclobber set noglob # # extract Configuration # set EXTRACT = $BIN/extract set CFGFILE = $CFG/$CAN.cfg set EXTRACT_OPTS = "-r -n -y 1 -c $CFGFILE" set DATAFILE = $CAN.$FILEBASE.00 set i = 0 while ( -e $RAW/$DATAFILE ) @ i++ set DATAFILE = $CAN.$FILEBASE.`printf "%02d" $i` end set ERRORFILE = $ERROR_DIR/$DATAFILE # # TNC Configuration # set TNC_CALL = 2002M2 set TNC_ADDR = "$TNC_CALL v TORO" # p: PACCOMM k: Kenwood n: None (requires wakeup hardware) set TNC_TYPE = p set TNC_PORT = tnc # # getoasis Configuration # #set DOWNLOAD = $BIN/getoasis -b 9600 -T $TNC_TYPE -p $TNC_PORT -a "$TNC_ADDR" -c $CAN -r $RCDFILE # # Fail Mail # set FAILMAIL = "headley@mbari.org,zorba@mbari.org,w3ab@mbari.org,eric@mbari.org" set ENABLE_FAILMAIL = $TRUE set MAIL_SUBJECT = "Failed OASIS Download" # oasisNT (Tower/Cygwin) #set MAIL = "mutt -x -s" #set MAIL_MSG = "** message from OASISNT $TNC_CALL **" # oasis (Tsunami/HPUX) set MAIL_MSG = "** message from OASIS $TNC_CALL **" set MAIL = "/bin/mailx -s" # # Data Monitor Configuration (oasisNT only) # #set DATAMON = $BIN/oasisc.tcl #set DRV = c: #set tclsh = /usr/bin/cygtclsh80 set MONITOR_ON = $FALSE #set OUTMON = "$tclsh $DRV$DATAMON exec,$DRV$BIN/decode -c $DRV$CFGFILE $DRV$RAW/$DATAFILE,,," #set OUTMON = ############################################# # Should not need to modify below this line # ############################################# cd $RAW # Record start of download set starttime = `date +"%x %H:%M:%S"` # Download the data and record error status $BIN/getoasis -b 9600 -T $TNC_TYPE -p $TNC_PORT -a "$TNC_ADDR" -c $CAN -r $RCDFILE >& $DATAFILE #$DOWNLOAD >& $DATAFILE set rtnsts = $status # Record the end of download set endtime = `date +"%x %H:%M:%S"` # Get the raw data filesize set filesize = `ls -l $DATAFILE | sed -f $BIN/fs.sed` # Log download statistics unset noclobber echo "$DATAFILE,$starttime,$endtime,$filesize,$rtnsts" >> $DLLOG.$FILEBASE echo "$DATAFILE,$starttime,$endtime,$filesize,$rtnsts" >> $OLDLOG set noclobber # # Send failmail # ## this barfs badly on HPUX and sends email to Download@... oasis@... and headley@... ## wtf???? #if ($ENABLE_FAILMAIL == $TRUE) then #if ( $rtnsts ) then # $MAIL $MAIL_MSG $FAILMAIL << ! #Download failure of file $DATAFILE #Return code was $rtnsts # 0 = Success # 1 = Argument error (bad command line arguments) # 2 = Couldn't acquire TNC port (hung download or someone's using port) # 3 = Couldn't connect to OASIS (it's not listening) # 4 = Download error (something broke after it connected) # 5 = Abort error (somebody killed the download) #`date` $MAIL_MSG #! #endif #endif if ( $rtnsts==0 ) then /bin/mailx -s "OASIS Download" $FAILMAIL << ! Download failure of file $DATAFILE Return code was $rtnsts 0 = Success 1 = Argument error (bad command line arguments) 2 = Couldn't acquire TNC port (hung download or port in use) 3 = Couldn't connect to OASIS (it's not listening) 4 = Download error (something broke after it connected) 5 = Abort error (somebody killed the download) `date` $MAIL_MSG ! endif # Extract data if ( (-e $DATAFILE) && !(-z $DATAFILE) ) then $EXTRACT $EXTRACT_OPTS $DATAFILE >& $ERRORFILE endif # Remove error file if no errors if ( -z $ERRORFILE ) then rm -f $ERRORFILE endif # Call download monitor to display data decode (oasisNT only) if ( $MONITOR_ON == $TRUE ) then # Use tcl client to tell tcl server to run decode $OUTMON endif