in reply to pipe help!

reader (ARGS)

The object is re-blessed into a sub-class of IO::Handle , and becomes a handle at the reading end of the pipe. If ARGS are given then fork is called and ARGS are passed to exec.
So what is happening is you are forking off a process such that the command is "echo" and the arguments to the command are "foo", ">" and "bar." So the behavior your are describing makes perfect sense to me. Maybe you want to
unless (fork()){ system ("echo foo > bar"); }

Not sure why you'd open a pipe on a command that doesn't return anything to stdout to be read by a pipe... just my thought....


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: pipe help!
by docdurdee (Scribe) on Aug 25, 2011 at 15:24 UTC

    Thanks Peter, that does make more sense. As to the why: I'm writing a program that runs many different (but similar) programs and does stuff with the output. Most of the programs (exe) print to stdout: exe <input > output so I can open a pipe on exe <input and deal with the output directly. there are some that don't print to standard out: exe input produces output files that I read in. I went in thinking I could just use the same pipe interface for everything and then read other files afterward. I ran into problems (which I still haven't nailed down) and that's how I end up with this question. D