Hi Perl folks,
No one replied to my posts about a wrapper script. I'm going to try
again.
I want to be able to process some command-line options, then call/exec
a separate command with my processed options, AND pass along the piped
input to that command as well.
For example, if I have a command called /bin/print-something, I would
normally call it like this:
# /bin/print-something -a -b some-option -c someother-option
But, I want to move that command to /bin/original-print-something, and
then replace it with my script. My script will read in those options
(maybe change them, maybe log something, whatever) and then exec the
original-print-something script with the now processed options. This
all works fine:
#/usr/bin/perl
use strict;
use warnings;
my @processed_args;
open LOG, ">>/tmp/wrapper.log" or die "Couldn't open /tmp/wrapper.log:
$!";
while( @ARGV ) {
# Here is where the args would be checked/changed/tweaked
push @processed_args, $new_arg;
}
print LOG "Contents of [EMAIL PROTECTED]: @processed_args\n";
exec '/bin/original-print-something', @processed_args or die "Couldn't
exec /bin/original-print-something: $!";
My problems come when I get a command-line like this:
# cat /etc/hosts | /bin/print-something -a -b some-option -c
someother-option
In this case, my LOG file will recored the args as "-a -b some-option -c
someother-option", but not the piped input. Where did it go? Is there
a variable that will contain that piped data so I can manipulate that
stuff, too?
--Errin
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>