nick has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I'm having some trouble with a perl script I'm writing. when I try to execute something on the command line, it just plain *doesn't work* i've used system & backticks (`). No luck, when I use (`) i get no output either... the command is:Failed! 13 It's that simple. I'm using system in other parts of this script and it works fine. I can even verify the system call is working, by creating a wrapper script. like so: (make_fs.pl) -------------------------------------------------------system("/sbin/mkfs -t xfs $device"); if (!?) { print "Failed! - $?\n"; }-------------------------------------------------------- (in the main script) --------------------------------------------------------#!/usr/bin/perl -w my $device = $ARGV[0]; print "I GOT $device !!\n"; system("/sbin/mkfs -t xfs $device"); exit($?);I GOT /dev/exampledevice0 Failed - 13 -------------------------------------------------------- Same, exit code, and the command never ran. the reason I know this is because. if, on the command line, I run that exact same command: # /sbin/mkfs -t xfs /dev/exampledevice0 the program formats it, if it had already been formatted it would ask for me to do a --force. So this is the first time it's been formatted. the script _is_ running as root. and when I print the $! output, it just says "illegal seek". now, if I use backticks (`) instead, this is what happens:#system("/sbin/mkfs -t xfs $device"); system("./make_fs.pl $device"); if (!?) { print "Failed! - $?\n"; }Failed! - 13 (no output from the first print) I have been coding in perl for over 2 years and never had this problem before. Any help GREATLY appreciated! - Nick#system("/sbin/mkfs -t xfs $device"); #system("./make_fs.pl $device"); print `/sbin/mkfs -t xfs $device`; if (!?) { print "Failed! - $?\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: calling an external program, from within a perl script
by trantor (Chaplain) on Aug 09, 2001 at 20:50 UTC | |
by softworkz (Monk) on Aug 09, 2001 at 21:32 UTC | |
by nick (Sexton) on Aug 09, 2001 at 21:38 UTC | |
by trantor (Chaplain) on Aug 09, 2001 at 22:39 UTC | |
by nick (Sexton) on Aug 10, 2001 at 11:28 UTC | |
|
Re: calling an external program, from within a perl script
by VSarkiss (Monsignor) on Aug 09, 2001 at 20:44 UTC | |
|
Re: calling an external program, from within a perl script
by mischief (Hermit) on Aug 09, 2001 at 21:46 UTC | |
by nick (Sexton) on Aug 10, 2001 at 10:58 UTC |