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;
In reply to communication between programs by earthfriendlyleaf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |