get the result of calling another script

B

B.W.

I want to call another script B in script A and get the result if the
execution of script B is successful, can someone show me how to do that?

thanks,
B.W.
 
B

Bob Walton

B.W. said:
I want to call another script B in script A and get the result if the
execution of script B is successful, can someone show me how to do that? ....
B.W.

I assume you mean Perl scripts. Check out the following docs:

perldoc -f system

perldoc perlop
paying special attention to the bit about the qx operator (or
'backticks') in the "Regexp Quote-like Operators" section.

perldoc -q "output of a command"

(or perldoc -q 'output of a command', depending on your OS)

Or do you perhaps mean you want to execute additional Perl code (which
you call "script B" from some other Perl code you call "script A",
without running another instance of the Perl interpreter in another
process? If that is the case, check out:

perldoc -f do

In that case, there is no issue with returning results, as the value of
the last statement executed is returned, or undef is returned if the
file can't be read or compiled, with either $! or $@ receiving the
error, depending. You will probably want to return something other than
undef if the code was properly executed.
 
T

Tad McClellan

B.W. said:
I want to call another script B in script A and get the result if the
execution of script B is successful, can someone show me how to do that?


! system 'script_B' or die "script_B failed";
 
J

Jürgen Exner

B.W. said:
I want to call another script B in script A and get the result if the
execution of script B is successful, can someone show me how to do
that?

See "perldoc -f system":
[...]
The return value is the exit status of the program as returned
by the "wait" call. To get the actual exit value divide by 256.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,154
Messages
2,570,870
Members
47,400
Latest member
FloridaFvt

Latest Threads

Top