in reply to Capture Exit Code Using Pipe & Tee

Do the tee yourself in Perl... that'd be a simple operation. Something like:
open my $make, "make -f params |" or die; open my $logger, ">>build.log" or die; while (<$make>) { print $logger $_; print } close $make; # to get $? my $exit = $?; close $logger;

Replies are listed 'Best First'.
Re^2: Capture Exit Code Using Pipe & Tee
by shmem (Chancellor) on Jan 31, 2007 at 21:46 UTC
    Always check the return value of close. You might be e.g. sitting on a NFS share.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re^2: Capture Exit Code Using Pipe & Tee
by Anonymous Monk on Jan 31, 2007 at 20:01 UTC
    I've tried your suggestion. I can't seem to get it to write anything anywhere now. Ideally I would like it to be real-time. I can't see in the example where the execution of make is taking place. Thanks for your help!!
      The make is invoked via open, which returns the process ID of the spawned command. merlyn's code should work alright, with a slight modification
      open my $make, "make -f params 2>&1 |" or die;
      to get make's STDERR into the spawning shell's STDOUT. Do you get any errors reported?

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}