in reply to checking on a system process
my $result=`sudo /bin/mount /dev/fd0 /mnt/floppy`; if ($?) { # there was an non zero return code print "There was an error: $?\n"; print $result } else { # looks like it worked }
With system you get the exit code of the forked child returned, perldoc suggests the following to handle errors.
Cheers,if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; }
|
|---|