Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > wrapper script calling anotherr script

Reply
Thread Tools

wrapper script calling anotherr script

 
 
bjlockie
Guest
Posts: n/a
 
      09-15-2012
I want to create a wrapper script (testa.pl) that defines variables (like $b) and can execute another perl program (testb.pl) that can access those variables.

I tried:
$ testa.pl 'testb.pl' but it didn't work.
I don't think eval is what I need but 'use' doesn't work on variables.


::::::::::::::
testa.pl
::::::::::::::

#!/usr/bin/perl -w

#use strict;
use warnings;

my $realScript = $ARGV[0];

(defined($realScript)) or die "Must specify a script\n";

print "This is $0\n";
my $b = 10;
eval $realScript;

print $@;



::::::::::::::

testb.pl

::::::::::::::

#!/usr/bin/perl -w

use strict;
use warnings;

print "This is $0, b=$b (should be 10)\n";

 
Reply With Quote
 
 
 
 
bjlockie
Guest
Posts: n/a
 
      09-15-2012
On Saturday, September 15, 2012 1:24:13 AM UTC-4, Eli the Bearded wrote:
> In comp.lang.perl.misc, bjlockie <(E-Mail Removed)> wrote:
>
> > I want to create a wrapper script (testa.pl) that defines variables

>
> > (like $b) and can execute another perl program (testb.pl) that can

>
> > access those variables.

>
>
>
> It's a strange thing to want to do, but Perl knows how to do this.
>
> You want to use "do".


I am using someone else's scripts that each have config data by using 'use configa'.
There is 'configb', 'configc', etc.
The current way of changing the config is to modifiy each 'use' in all the scripts.
With the wrapper, I can have the 'use configx' in one place and use 'do' to call the other scripts.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone willing to share an SUID wrapper program to take/passarguments to a shell script on Unbuntu? bobm3@worthless.info C Programming 3 01-15-2012 05:53 PM
Python without wrapper script eric.frederich Python 5 12-03-2009 03:16 PM
C set-user-ID program wrapper for Perl script and security Peter Michaux C Programming 19 09-10-2008 08:17 PM
My humble contribution - wrapper script for dcraw (linux) bizcotti@gmail.com Digital Photography 1 04-01-2007 01:57 AM
Calling Different scripts with 1 wrapper script qazmlp Perl Misc 5 01-02-2005 02:02 PM



Advertisments