ladcp2
changeset 5 f41d45fe7ae9
parent 4 fda11de1826e
child 12 5e67754f6457
equal deleted inserted replaced
4:fda11de1826e 5:f41d45fe7ae9
     1 #!/usr/bin/expect -f
     1 #!/usr/bin/expect -f
     2 #======================================================================
     2 #======================================================================
     3 #                    L A D C P 2 
     3 #                    L A D C P 2 
     4 #                    doc: Wed Mar 10 22:23:52 2004
     4 #                    doc: Wed Mar 10 22:23:52 2004
     5 #                    dlm: Thu Aug 26 00:27:14 2010
     5 #                    dlm: Fri Dec 10 14:28:20 2010
     6 #                    (c) 2004 A.M. Thurnherr
     6 #                    (c) 2004 A.M. Thurnherr
     7 #                    uE-Info: 31 39 NIL 0 0 72 2 2 8 NIL ofnI
     7 #                    uE-Info: 70 34 NIL 0 0 72 2 2 8 NIL ofnI
     8 #======================================================================
     8 #======================================================================
     9 
     9 
    10 # HISTORY:
    10 # HISTORY:
    11 #  Mar 10, 2004: - created
    11 #  Mar 10, 2004: - created
    12 #  Mar 12, 2004: - released
    12 #  Mar 12, 2004: - released
    19 #  Oct 31, 2007: - BUG: wrong default on non-empty memory
    19 #  Oct 31, 2007: - BUG: wrong default on non-empty memory
    20 #  Nov 19, 2008: - adapted to new firmware behavior (load_factory_defaults)
    20 #  Nov 19, 2008: - adapted to new firmware behavior (load_factory_defaults)
    21 #  Nov 19, 2008: - added version
    21 #  Nov 19, 2008: - added version
    22 #  Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect
    22 #  Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect
    23 #		 - libBB.expect -> libRDI.expect
    23 #		 - libBB.expect -> libRDI.expect
       
    24 #  Dec 10, 2010: - allow restarting a cast with same number
    24 
    25 
    25 #----------------------------------------------------------------------
    26 #----------------------------------------------------------------------
    26 # Setup
    27 # Setup
    27 #----------------------------------------------------------------------
    28 #----------------------------------------------------------------------
    28 
    29 
    52 }
    53 }
    53 
    54 
    54 if ![file isdirectory $raw_dir] {
    55 if ![file isdirectory $raw_dir] {
    55 	error "directory $raw_dir does not exist";
    56 	error "directory $raw_dir does not exist";
    56 }
    57 }
       
    58 
    57 set cast_dir [format %s/%s $raw_dir $stnstr];
    59 set cast_dir [format %s/%s $raw_dir $stnstr];
    58 if [file isdirectory $cast_dir] {
    60 if [file isdirectory $cast_dir] {
    59 	error "data directory $cast_dir already exists!";
    61 	if {![affirm "WARNING: data directory $cast_dir exists --- are you sure station number $stnstr is ok? (y/N) " 10]} {
       
    62 		send_error "$argv0 aborted\n";
       
    63 		exit 0;
       
    64 	}
       
    65 	set attempt 1;					# rename
       
    66 	while {[file isdirectory $cast_dir.aborted$attempt]} {
       
    67 		set attempt [expr $attempt + 1];
       
    68 	}
       
    69 	exec mv $cast_dir $cast_dir.aborted$attempt;
       
    70 	send_user "data directory $cast_dir renamed to $cast_dir.aborted$attempt\n"
    60 }
    71 }
       
    72 
    61 set prev_cast_dir [format %s/$stn_format $raw_dir [expr $stn - 1]];
    73 set prev_cast_dir [format %s/$stn_format $raw_dir [expr $stn - 1]];
    62 if {![file isdirectory $prev_cast_dir]} {
    74 if {![file isdirectory $prev_cast_dir]} {
    63 	if {![affirm "WARNING: previous-station data directory $prev_cast_dir does not exist --- are you sure the station number $stnstr is ok? (y/N) " 10]} {
    75 	if {![affirm "WARNING: previous-station data directory $prev_cast_dir does not exist --- are you sure station number $stnstr is ok? (y/N) " 10]} {
    64 		send_error "$argv0 aborted\n";
    76 		send_error "$argv0 aborted\n";
    65 		exit 0;
    77 		exit 0;
    66 	}
    78 	}
    67 }
    79 }
    68 
    80