checkfiles1
author A.M. Thurnherr <ant@ldeo.columbia.edu>
Mon, 12 Oct 2009 16:56:59 -0400
changeset 0 648bde652211
child 4 fda11de1826e
permissions -rwxr-xr-x
created from V1.4beta

#!/usr/bin/expect -f
#======================================================================
#                    C H E C K F I L E S 1 
#                    doc: Wed Mar 10 22:23:52 2004
#                    dlm: Wed Nov 19 15:11:21 2008
#                    (c) 2004 A.M. Thurnherr
#                    uE-Info: 27 14 NIL 0 0 72 2 2 8 NIL ofnI
#======================================================================

# HISTORY:
#  Jun 27, 2004: - adapted from [endladcp1] to allow continuation after
#		   download ok
#  Feb 14, 2006: - BUG: no logging was done
#  Oct  4, 2006: - adapted to older expect version
#  Oct 28, 2006: - adapted to older expect version
#  Nov 19, 2008: - added version

#----------------------------------------------------------------------
# Setup
#----------------------------------------------------------------------

log_user 0;
source DEFAULTS.expect;
regsub {dir1} [exec which dir1] {libBB.expect} path;
source $path;

print_version;

if ![file isdirectory $raw_dir] {
	error "directory $raw_dir does not exist";
}

#----------------------------------------------------------------------
# Get Station Number
#----------------------------------------------------------------------

spawn bbabble -ms $tty0;

set_color;
send_user "Connecting to instrument...";
wait_for_startup;
reset_instrument;

send_user "\nGetting station number...";
set deployment_name [get_deployment_name];
if {[scan $deployment_name $master_deployment_name_fmt stn] != 1} {
	send_error "$deployment_name $master_deployment_name_fmt";
	error "Can't get station number";
}
set stnstr [format $stn_format $stn];
send_user "\[$stnstr\]";

set cast_dir [format %s/%s $raw_dir $stnstr];
if {![file isdirectory $cast_dir]} {
	put_to_sleep;
	error "cast directory $cast_dir does not exist!";
}

cd $cast_dir;
send \004;

#----------------------------------------------------------------------
# Check & Backup Data
#----------------------------------------------------------------------

regsub {.*/} $argv0 {} basename;
start_logging [format %s_%s.log $basename $stnstr];

send_user "\nChecking data file...\n";
set_color 0;
check_data [format %s000.000 [format $master_deployment_name_fmt $stn]];
set_color;

send_user "Backing up data file...";
backup_master_data $stn;

send_user "\nDone\n"