melguin has asked for the wisdom of the Perl Monks concerning the following question:
So far I have this:
my $device = "/dev/cdrom"; my $dir = "/mnt/cdrom"; my $testfile = ""; print `mount $device $dir`; if ($?) { if ( -f "$dir/$testfile" ) { print "mounted." } else { print "There was an error in mounting $device at $dir. +\n" } } else { print "mounted\n" }
This works, but I would like more info about the error. I thought that doing something like this:
$output = `mount $device $dir`;
would get me what's being displayed to the screen (eg. "..mounted read only..", "only root can do that", etc.), but alas I was mistaken.
Anyone know of a good way to do that?
thanks.
melguin.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting output from backticks
by bikeNomad (Priest) on Jul 19, 2001 at 03:05 UTC | |
|
Re: getting output from backticks
by buckaduck (Chaplain) on Jul 19, 2001 at 03:10 UTC | |
|
Re: getting output from backticks
by MZSanford (Curate) on Jul 19, 2001 at 15:14 UTC | |
|
(jeffa) Re: getting output from backticks
by jeffa (Bishop) on Jul 19, 2001 at 02:48 UTC | |
by melguin (Pilgrim) on Jul 19, 2001 at 02:59 UTC | |
by Wookie (Beadle) on Jul 19, 2001 at 13:49 UTC | |
|
Re: getting output from backticks
by jlongino (Parson) on Jul 19, 2001 at 20:47 UTC |