in reply to How to verify mount point

You could use unless control structure to execute the code in the block just upon successful mount:
use strict; use warnings; use File::Copy; my $usbdev = "/dev/sdb1/"; my $usbmount = "/media/usb/"; my @files = qw( file1 file2 file3 ); # or read from the filesystem usi +ng a glob or directory handle unless ( system "mount $usbdev $usbmount" ) { # Return was zero - meaning success for my $file (@files) { copy($file,$usbmount) or warn "Failed to copy $file: $!\n"; } ! system "umount $usbmount" or die "Can't umount $usbmount\n"; }

Have a nice day, j

Replies are listed 'Best First'.
Re^2: How to verify mount point
by Mery84 (Novice) on Mar 26, 2012 at 07:55 UTC
    Many thanks for this example - this is short, simple and works excellent.
    Thanks to all of you Monks for your support :).