in reply to Re: capture stdout and stderr from external command
in thread capture stdout and stderr from external command
I am running these external commands in Windows and I want to run 60 of the 5000 external commands that I have at any given point of time. When one of the external commands is done I need to run another such that I have 60 external commands executing at any given time. Thats the reason why I have been using perl's forkmanager which forks the process and limits them to the max procs (60 in my case). Now all I need is to get the stdout and stderr of these external commands which run from the forked child process.
my $max_procs = 60; my $pm = new Parallel::ForkManager($max_procs); foreach my $child ( 0 .. $#cmds ) { my $pid = $pm->start($cmds[$child]) and next; # This is where I need to get the stdout and stderr. # cmds can be external command which can be windowsexecutable.exe +$args (for example perl.exe script.pl $arg1 $arg2) system("cmds"); my $Result = $? >> 8; $pm->finish($Result); # pass an exit code to finish } $pm->wait_all_children;
The above sample code set the $max_procs to 60 and forks 60 child process each executing one system command. All I need is to get the stdout and stderr of the executable executed using the system command into some perl variable
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: capture stdout and stderr from external command
by zwon (Abbot) on Nov 12, 2011 at 03:33 UTC | |
|
Re^3: capture stdout and stderr from external command
by zentara (Cardinal) on Nov 12, 2011 at 11:15 UTC | |
|
Re^3: capture stdout and stderr from external command
by remiah (Hermit) on Nov 12, 2011 at 02:22 UTC |