----- Original Message ----- From: "Larsen, Errin M HMMA/Information Technology Department" <[EMAIL PROTECTED]> Date: Tuesday, June 28, 2005 11:25 am Subject: RE:Wrapper Script
> Hi Perl folks, Hello Errin > > 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/execa 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 > wouldnormally 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'texec /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 > therea variable that will contain that piped data so I can > manipulate that > stuff, too? I think the problem may be in the function that process your ARGS. I am refereing to the function which sets $new_args. You would need to showe us some more code to get more help. > while( @ARGV ) { > # Here is where the args would be checked/changed/tweaked > push @processed_args, $new_arg; > } Mark G. > > --Errin > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>