in reply to redirecting STDOUT (of a system call) to a var

i've been alltogether unsatisfied with this situation myself, as seen in a past post of mine~
once again: program output and return code. though in my environment, i was able to change code to use IPC::Open3, and capture STDOUT and STDERR.

what i cannot do is capture STDOUT, STDERR, and the exit code. hopefully at some point in the future, this will be remedied.

ACK!!!

~Particle

  • Comment on Re: redirecting STDOUT (of a system call) to a var

Replies are listed 'Best First'.
(tye)Re: redirecting STDOUT (of a system call) to a var
by tye (Sage) on Jun 28, 2001 at 19:27 UTC

    Doesn't calling waitpid() (as documented) after using open2() or open3() also give you the exit status?

            - tye (but my friends call me "Tye")

      BRILLIANT!

      now i call waitpid(-1,0), and the value of $? is the return value from the open! this will make my programming life MUCH easier!

      thank you tye.

      in case this helps anyone else, the code that's changed is:

      eval { $pid = open3("<&STDIN", \*OUTPUT, \*OUTERR, 'perl return.pl') ; $val = waitpid(-1,0); # <--- added this line }; ... print "---pid$n"; print $pid . $n; # <--- prints pid print "---val$n"; print $val . $n; # <--- prints pid print "---\$?$n"; print $? >>8, $n; # <--- prints exit val
      i am amazed. and VERY happy.

      ~Particle