Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Executing perl script from perl scripts

by moritz (Cardinal)
on May 15, 2008 at 13:11 UTC ( [id://686725]=note: print w/replies, xml ) Need Help??


in reply to Executing perl script from perl scripts

In a test file you should call the scripts in the same what that cron does, which is through a system call or the shell.

You can do that in perl like this:

system($^X, '1.pl'); # and check for system's return value! ok(1, 'Test 1'); system($^X, '2.pl'); ok(2, 'Test 1');

If you want to process the script output, use

my $res = qx($^X 1.pl); chomp $res; is($res, 1, '1.pl worked'); $res = qx($^X 2.pl); chomp $res; is($res, 2, '2.pl worked');

($^X is the path of the current perl interepreter)

Replies are listed 'Best First'.
Re^2: Executing perl script from perl scripts
by palette (Scribe) on Jun 18, 2008 at 06:32 UTC
    Getting an error on executing 1.pl should throw error telling that 1.pl is errored. 1.pl might not return a value '1'. What can be done in that case.
Re^2: Executing perl script from perl scripts
by palette (Scribe) on May 16, 2008 at 10:26 UTC
    If I want to run 1.pl with one version of perl and the 2.pl with another version of perl how can I do that
      system qw(perl5.8.8 1.pl); system qw(perl5.10.0 2.pl);
      /first_perl_location/bin/perl 1.pl /second_perl_location/bin/perl 2.pl
      Cheers,
      Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://686725]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found