On Tue, 2002-09-10 at 14:09, Stuart wrote:
> Hi there
>
> As I'm into Java but have inherited a perl script for backups can anyone
> relate to me how in perl you tell if a mount succeeds?
the easiest way is to check the return code of mount. system() returns
this, so it should be something like
if (system($mountcmd)) {
die "couldn't mount stuff";
}
# other stuff here.
or if you want retries you could use something like this:
my ($retries, $maxretries) = (0, 5);
my $returncode;
while ($returncode = system($mountcmd) && $retries++ < $maxretries) {
print stderr "I'm broken\n";
sleep 30;
}
if ($returncode) {
die "couldn't mount stuff";
}
# other stuff here.
the thing to remember about return codes is that they're 0 when it has
succeeded, not when it has failed.
disclaimer: all code untested but it looks approximately right.
HTH
James.
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug