wrapper script and GetOpts::Long perl

134 Views Asked by At

I have been trying to make GetOpts :: Long work for my code but it just doesn't respond. I have a wrapper script with about 8 scripts and 2 commands. I have been trying to GetOpts :: Long submit arguments into the separate codes, but it doesnt work!

For example, I've script 1 though 8, and on the command line I'm trying to a few options that I would like to submit to the separate scripts. When I use the GetOpts module in the seprate scripts and run them separately, they run fine. But when I try to run the wrapper script, say wrapper.pl which initiates script 1 with the module being called in it; the arguments submitted are not being taken by the separate scripts.

Please help!!!!

I hope this sort of explains the problem. wrapper script looks like this(wrapper.pl),using backticks:

perl script1.pl;

perl script2.pl; (etc)

script1.pl uses the GetOpts::Long option for the input file. script1.pl calls for the input file using the "-i" option, but the file is not being read when initiated on the command line.

command line option: perl wrapper.pl -i seqs.fa -o op.fa

1

There are 1 best solutions below

0
Armali On

Do you actually pass in the arguments from your wrapper.pl into the scripts ? - how would they magically know what options they need to handle?

vanHoesel asked the right questions; you have to do something like that in wrapper.pl:

use Getopt::Long;
GetOptions('i=s' => \$input_file,
           'o=s' => \$output_file) || die "Usage: $0 -i INPUT -o OUTPUT\n";
`perl script1.pl -i $input_file`;
`perl script2.pl -o $output_file`;