Andrew Tait wrote:
>
> Hi All,
>
> At the moment I am using the system() fuctions to run external commands as
> follows:
>
> print "Run \"userdel -r $arg\" [y/N] ";
> chop ($answer=<STDIN>);
> if ($answer =~ /^y/i) {
> print "Deleting account....";
> system("userdel -r $arg");
> print "....Done\n";
> }
>
> However, if "system("userdel -r $arg");" prints any errors, nothing appears
> on screen! For example, I am runng this script as a normal user (not root),
> which should print the following error.
>From perldoc -f system, I got the canonical syntax:
@args = ("command", "arg1", "arg2");
system(@args) == 0 or die "system @args failed: $?"
In your case it means:
system("userdel","-r",$arg) or die "....";
The or die assignment should always be on a system call.
The other way is to use backticks:
`userdel -r $arg`
Greetings,
Andrea
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]