Hi, I want to run a shell command with the following constraints: a. I like to get the return code of the command b. Furthermore I want to combine stdout and stderr so that the output comes in a natural sequence like in the shell. c. I don't want to capture the output in a variable (because the output could be really large and I don't want to wait for the first line of output)
I did this: use IPC::Open3; sub run_cmd { my $cmd = shift @_; my $pid = open3(undef, *CMD_OUT, *CMD_OUT,$cmd); while ( <CMD_OUT>) { print "$_"; } waitpid($pid,0); my $rc = $? >>8; return $rc; } I tested the code and it I can say it worked fine under fair weather conditions. Question: Is the code ok, or could it be improved, or has it even flaws? -- Thanks, Manfred -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/