Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Peeps

I have two scripts, one on my website (signup.pl), and one that is chmod 4750 (addme.pl) so that it can perform certain functions as root.
Signup.pl passes certain information on to addme.pl using the !system command to trap any errors. If there was an error running addme.pl, then signup.pl transfers the user to a static page, explaining the _possible_ causes of the problem.

What i realy want is signup.pl and addme.pl to talk to eachother. When an error is detected running addme.pl, i want addme.pl to pass the error message over to signup.pl so that signup.pl can display exactly what is wrong to the user.

I hope i have explained this reasonably well!!

Replies are listed 'Best First'.
Re: A Reason To Die!
by Abigail-II (Bishop) on May 17, 2003 at 00:14 UTC
    There are many ways you can accomplish this. To name a few:
    • addme.pl doesn't output any error messages. Instead, it just exits with a particular value. signup.pl captures the exit code, and uses a lookup table to see what happened.
    • You'd use IPC::Open3 to open addme.pl, and read from its standard error what the error is.
    • $err = qx /addme.pl 2>&1/;

    Abigail

Re: A Reason To Die!
by tall_man (Parson) on May 16, 2003 at 23:01 UTC
    Even better than a reasonable explanation would be some source code. In general, running a perl script with setuid root is a serious security risk, especially if you allow a web user to pass any information to it. I wouldn't compound the risk by returning any output from that script, because they might be able to get sensitive information that way.