The original email is at the end.
The basic problem is the placement of the "if ($status ...) then"
variable check. I was actually checking the status of the command before it
(echo "...") not the dump command.
There are several solutions:
1) Don't write script files in csh (4).
2) Use a "set tempstat = $status" as the next line after this dump
command, and then evaluate the $tempstat variable at a later point in the
script.
3) Place the "if ($status != 0 ) then " as the next command after the
dump command.
4) $status is not supported in csh (It is)
I elected to try #3. I made the change, and I will let the script run
tonight to see what happens. But I suspect this is it.
Thanks for not rubbing it in.
Dave
Original email:
This is really stupid, I know.
I have a script file that I am using to dump my filesets to a 8505XL. I
want it to stop when an error occurs. I thought the $status variable would
work. It isn't.
What am I doing wrong?
Or is it working right, but I am expecting too much from dump?
Here is the code fragment:
#!/bin/csh
...
...
while (1)
set filesys=$< /* List of files from the command line. */
if ( "$filesys" == "EOF" ) then
break
endif
if ( "$filesys" != "" ) then
set FTEMP=` echo $filesys | cut -f1 -d' ' `
set DISKPAR=` echo $FTEMP | cut -f2 -d: `
echo "--- Dumping $filesys to tape ---" >>& ${LOGFILE}
($DUMP $DUMPOPS $TAPEDEV $DISKPAR) >>& $LOGFILE
echo " " >>& $LOGFILE
if ( $status != 0 ) then /* <-- This should be 0, unless an error */
echo "An Error Occurred while dumping $DISKPAR" >>& $LOGFILE
echo "Aborting the remaining dumps" >>& $LOGFILE
echo "Fix this problem ASAP " >>& $LOGFILE
exit (1) /* This should get me out of the While loop on a dump error. */
endif
endif
end
>
According to the man pages, dump will give me a:
0 Normal exit. /* Looks self explanatory - Unless a normal exit is
anything that didn't lockup or crash */
1 Startup errors encountered. /* What kind of Startup Errors? */
3 Abort - no checkpoint attempted. /* Clear as mud. ?? */
Basically, if the dump does not complete successfully (backup the fileset
to tape, completely), for any reason, I want the script to exit the While
loop, and finish the script (email the $LOGFILE and do some clean up).
I suspect it is working as written, but dump does not consider most
errors to be serious enough to flag. It finishes with a "Normal Exit" even
though it ran out of tape, or didn't have enough tape to start.
SunOS 4.1.4 on an SS10.
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:11 CDT