| [reply] |
Now, output that *should* be going to ">outfile" is actually being printed/redirected to the screen.
Could you give us a short a short runnable program that demonstrates this?
And are you sure the child is writing to its STDOUT and not its STDERR? Try
system("somecmd -args >outfile 2>&1");
| [reply] [d/l] |
| [reply] |
Does your code contain close STDIN;? If yes, does it also contain: open STDIN, "<", "/dev/null";? | [reply] [d/l] [select] |
Nevermind...stupid yet subtle mistake...
I wasnt chomping the result from STDIN... should have done this:
chomp($filename=<STDIN>);
this removes the newline character which kept getting inserted into $filename, giving $filename a value such as '/path/file\n', and thus passing the newline into my $cmd string, making $cmd look like this:
$cmd = "mycmd -args $filename >outfile" ...gives...
"mycmd -args /path/file\n >outfile"
So, everytime I passed $cmd to system(), it would execute the cmd and stop at the newline character embedded within $filename, thus skipping the ">outfile" redirection...
problem solved, but thanks to everyone for pointing out that this apparently should have worked.
Please add this to your vast collection of mental "gotchas" that can stump users...
| [reply] |