Martín Alejandro Carmona Selva wrote:
> Hello, i am a little more than just a newbie to perl...
> I am writting some perlbased XMLRPC to perform actions on my server
> as I connect via web.
> 
> i am doing a simple task (adding an user) but, no matter how hard I
> try I cannot get the result from that command into the variable.
> 
> Let me put the example code fot you to guide:
> 
> $rescmd =""; # no error by default
> $cmd = "useradd -s /bin/false $useradd";
> $rescmd = `$cmd`;
> 
> The problem is that $rescmd stays empty. I know that it will be empty
> if everything goes okay (since well, useradd returns nothing if no
> error occours), but I'm trying to create an already existing user (to
> get the error).

Error messages typically go to stderr, which backticks don't capture. You
should try duping stderr onto stdout:

   $cmd = "useradd -s /bin/false $useradd 2>&1";

You can also get the exit status from $?

(n.b. you should run your script with -T and untaint $useradd if it is
derived from outside your script, making sure it doesn't include other nasty
characters. Read perldoc perlsec for more details.)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to