TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

perl question



        hate to ask more tiresome questions, but...
        I wrote a trial script, and it seems to work. However, I would like
it to be more robust (because unexpected failures could be very bad in this
case).
        I need to make sure that a given SMB share is mounted, before I do a
backup. (I've had the share not respond to the mount; and done backups on
empty space).
        I'm guessing that the 'die' option will let me exit gracefully from
a failed command; that seems to be what it's there for. (can't find it
readily explained in the man pages anywhere, only examples of its use; nor
does perl.com's search engine provide me with help)

        however, with this script:
#!/usr/bin/perl
if (-e "/mnt/e/HERDS") {
        print "/mnt/e/HERDS exists! \n";
        `/usr/bin/smbumount /mnt/e` or die "Unmount failed!";
        }
else {
        print "/mnt/e/HERDS does not exist! \n";
        `/usr/bin/smbmount //nonexistent/share -c "mount /mnt/e"` or die
"Mount failed!";
        }

it unmounts the share in the first case; but still gives me the "Unmount
failed" error.
in the second case, it doesn't mount the share; but doesn't give me the
"Mount failed" error.

is the execution of the shell command returning an incorrect code, compared
to what 'die' is looking for?
or am I barking up the wrong tree here?

do people have any advice for making scripts more robust?

Carl Soderstrom
System Administrator	307 Brighton Ave. 
Minnesota DHIA		Buffalo, MN	
carls@agritech.com	(612) 682-1091