Re: Pipe input over several scripts



Hi,

The problem is that script c is not getting the input.

Script A:
#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open2;

my @input = ('test1', 'test2', 'test3', 'test4');
my $out = "";
my $timeout = 7200;
my $RDR;
my $WTR;
my $cmd = 'perl script_b.pl';

my $pid = open2($RDR,$WTR, $cmd) || die("ERROR: Could not execute: " .
$cmd);

foreach (@input){
print $WTR $_."\n";
}
close($WTR);

if (defined $RDR) {
while (<$RDR>) {
$out .= $_;
}
}
print "\n\n";
print $out;
wait; # wait till prozess with $pid dies
print "Script A finished\n";



Script B:
#!/usr/bin/perl
use strict;
use warnings;
my $input = '';

print "Input 1: ";
chomp($input = <STDIN>);
print $input."\n";

print "Input 2: ";
chomp($input = <STDIN>);
print $input."\n";

system('perl script_c.pl');
print "Script B finished\n";



Script C:
#!/usr/bin/perl
use strict;
use warnings;
my $input = '';

print "Input 3: ";
chomp($input = <STDIN>);
print $input."\n";

print "Input 4: ";
chomp($input = <STDIN>);
print $input."\n";

print "Script C finished\n";
.



Relevant Pages

  • Re: A script to flag commonly misused words
    ... is preferable in general as it allows you to scope warnings. ... use strict; ... I first wrote a script to extract the words to flag from your ... I discovered that at least one of the expressions you ...
    (comp.lang.perl.misc)
  • Re: [PATCH] Speed up "make headers_*"
    ... 'use strict' and 'use warnings' is recommended. ... The parentheses are not needed for most of the built-in functions. ... More or less the same comments would apply to the next script as well. ...
    (Linux-Kernel)
  • Re: Regular Expression and file editing.
    ... Goksie wrote: ... If i run the script, the changes could not be effected bcos the files is ... use warnings; ... use strict; ...
    (perl.beginners)
  • Re: Counting column delimiters per row in a text file
    ... Then parse (see the parse method) ... This can't be more than 20 lines or so including use strict and use ... Put the data in the __DATA__ section of your script. ... use warnings; ...
    (comp.lang.perl.misc)
  • Re: Passing vars to a "require"d script
    ... > require'd script didn't seem to pull in the form data, ... >> use strict; ... >> use warnings; # main program ...
    (comp.lang.perl.misc)