...i am trying to write a shell script that will run 5 of my programs in sequential order.
Are these programs shell scripts, perl scripts, or what?
...however i don't know how to do it so that the input files can be different
I do not quite understand this one.
...i also want to pipe the out put file so that it can be the input file of the next program.
If the 5 programs are perl scripts why not condence them into 5 subroutines included in the same script? ;) If the programs are shell scripts just feed their output into an array and process by passing each value to another subroutine.
Assuming you are taking output from running the other scripts, here is an example of my understanding.
3 scripts: start.pl, hello.pl, and chopup.pl
start.pl
#! /usr/bin/perl -w
use strict;
my @program1 = `perl ./hello.pl`;
foreach (@program1) {
# pass to program2
&program2($_);
}
sub program2() {
# value from program1
my $value = shift;
my @newvalue = `echo $value | perl ./chopup.pl`;
foreach (@newvalue) {
print $_;
}
}
hello.pl
#! /usr/bin/perl -w
use strict;
my $message = "Hello Lucy!";
print "$message";
chopup.pl
#! /usr/bin/perl -w
use strict;
chomp (my $value = <STDIN>);
my @value = split "",$value;
my $count = @value;
my $i;
for ($i=0;$i<$count;$i++) {
print "\@value[$i] = $value[$i]\n";
}
Run ./start.pl and all files will be processed. I hope this helps, or maybe I should say I hope my understanding is correct! ;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.