earthfriendlyleaf has asked for the wisdom of the Perl Monks concerning the following question:
I have multiple scripts running at the same time. Each scripts is running in its own windows command prompt instance.
I would like to have a master script that opens all the other scripts, and then collects the info from the other scripts.
I have been looking into using a piped open. The idea is to open each script from the master script with a statement like open JOB1, 'perl job1.pl|'. It kinda works except that I am having issues reading the data. I am trying to use IO::Select to know when there is data available to be read. I would be grateful if someone could look at my code and let me know if I am doing something wrong or if I am going about this the right way.
Thanks!
use IO::Select; my $read_set = new IO::Select(); #create handle set for reading open JOB1, 'perl test1.pl|' or die "cannot pipe to perl: $!"; open JOB2, 'perl test3.pl|' or die "cannot pipe to perl: $!"; my $read_set->add(JOB1); my $read_set->add(JOB2); while (1) { my $rh_set = IO::Select->select($read_set, undef, undef, 0); foreach my $rh (@$rh_set) { my $output = <$rh>; print $output2; print "in foreach $rh\n"; } } close JOB1; close JOB2;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: communication between programs
by Corion (Patriarch) on Sep 12, 2011 at 13:48 UTC | |
by earthfriendlyleaf (Initiate) on Sep 12, 2011 at 14:08 UTC | |
|
Re: communication between programs
by BrowserUk (Patriarch) on Sep 12, 2011 at 16:09 UTC | |
|
Re: communication between programs
by zentara (Cardinal) on Sep 12, 2011 at 14:31 UTC | |
|
Re: communication between programs
by moritz (Cardinal) on Sep 12, 2011 at 13:48 UTC | |
|
Re: communication between programs
by ambrus (Abbot) on Sep 13, 2011 at 08:50 UTC |