in reply to Backup script: how can I force this to report errors?

I'm not sure whether I'm doing something wrong, or you are doing something wrong, but when I do this:
perl -e 'system ("tar cf /home/yup/yup.tar .") and die "Oops: $?\n";'
I get:
tar: /home/yup/yup.tar: Cannot open: No such file or directory tar: Error is not recoverable: exiting now Oops: 512
So $? is definitely set, and tar's exit code was 512 >> 8 = 2. Are you sure _barf does not get called?

As an aside, I assume you predeclare _barf in the omitted initialisation section, as the way the script is written the call to _barf will not work.

CU
Robartes-

Replies are listed 'Best First'.
Re^2: Backup script: how can I force this to report errors?
by LAI (Hermit) on Mar 20, 2003 at 17:21 UTC

    Oh, _barf works as expected. If you like I can show you the full code. The difficulty is with (presumably) either mt or with /dev/st0. I'm looking for a perlish way to figure out if there is a tape in the drive.

    If you have access to a machine with a tape drive (no idea if this will only apply to SCSI tapes), make sure there is no tape in the drive and try the following:

    [root@mag /]# mt -f /dev/st0 stat SCSI 2 tape drive: File number=0, block number=0, partition=0. Tape block size 0 bytes. Density code 0x25 (DDS-3). Soft error count since last status=0 General status bits on (41010000): BOT ONLINE IM_REP_EN [root@mag /]# mt -f /dev/st0 load [root@mag /]# mt -f /dev/st0 seek [root@mag /]# mt -f /dev/st0 fsf [root@mag /]# touch testfile ; tar -cvf /dev/st0 testfile testfile [root@mag /]# tar -tf /dev/st0 tar: This does not look like a tar archive tar: Skipping to next header tar: Error exit delayed from previous errors [root@mag /]#

    See, all the seeking, writing, and so on should return errors (or at least warnings) but doesn't.

    LAI

    __END__