in reply to How to capture log from external interactive process

If you are shell scripting on a Unix box, and your system call is tantamount to that, the exit code/return value of the command-just-run is stored in the variable '$?'. Perl does a similar thing with this variable. NOTE: because it changes every time a child process is run, if you want to preserve this value, you need to save it off, a la this shell sniplet:

rc=$? if [[ ${rc} -ne 0 ]]; then echo "cp -i $file1 $file2 failed with a value of ${rc}" fi

Hope this helps.

--
tbone1, YAPS (Yet Another Perl Schlub)
And remember, if he succeeds, so what.
- Chick McGee

Replies are listed 'Best First'.
Re^2: How to capture log from external interactive process
by sintadil (Pilgrim) on Sep 17, 2004 at 14:30 UTC

    rc=$? if [[ ${rc} -ne 0 ]]; then echo "cp -i $file1 $file2 failed with a value of ${rc}" fi

    Thank you for reminding me of why I shall never, ever learn shell scripting and shall forever stick with Perl. :)

      Thanks for your help guys, but I'm still stumped.

      Script may well work but I need to do all this from a perl script.

      1) execute external program from perl
      2) using perl or shell scripting magic, log the programs output and user input
      3) use perl to check the exit status of the program

      I've tried using perl's open3, but then stdout/stderr/stdin all get piped to perl :(