in reply to perl, open and pipe

What am I doing wrong here?I think the pipe is messing everything up.

No, the pipe is fine. Jusr redirect stderr (fileno 2) to stdout (fileno 1):

open(SY, "echo blablabla|/usr/bin/js 2>&1|") or die "$!"; while(<SY>){ print ">>$_"; }

Replies are listed 'Best First'.
Re^2: perl, open and pipe
by afoken (Chancellor) on May 11, 2010 at 05:33 UTC

    Depending on what /usr/bin/js does, that might be a bad idea. 2>&1 mixes STDERR and STDOUT into a single stream, so you may have a hard time "unmixing" them. If you need both STDOUT and STDERR, don't use open "...2>&1 |", but create two pipes manually or using IPC::Open3. If you need only STDOUT, use open "... 2> /dev/null |", if you need only STDERR, use open "... 2>&1 > /dev/null |".

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Since in the OP 'twas said
      I want to catch that error (or any result from the /usr/bin/js program).

      a single stream fits the task. Managing two file descriptors would be a YAGNI in that case.