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

Hi, Actually i have a problem in my coding. i have come to this site to find out the solution. Problem : 1 perl program(a) is starting another prog(b) using system command. if the second prog(b) contains any error, i have to show the error details to my client. how can i get the error messages from the prog. i have tried perl -c option. i want to check the syntax and get all the problems in the second prog. don't check my english skills. plz send the message if you know anything about this problem. Vijay

Replies are listed 'Best First'.
Re: Problem in my coding
by Corion (Patriarch) on Mar 16, 2008 at 18:32 UTC

    I already told you this in the chatterbox.

    It's easiest is to redirect the output. Many shells allow you to capture the error output via

    2> errorlog
    . Or call your program via
    my @output = `$program 2>&1`
    Otherwise, look at IPC::Run.

      In addition, check the value of $? after the system call. It contains a processed value of the exit code of the program (divide by 256 and you'll get very close), it'll be non-zero if there was an error.