How to fetch output of some other script in the current running perl script?

R

ritugoyal12

Hi,
I want to execute some script (May or May not be perl script) from a
perl script and print the output of that executed script.
My Operating system are Windows and Mac OS(Unix).
I was trying the following code without success:


Code
$Response = system("start test.wbt");
print $Response;

By the above code I am able to execute test.wbt but program doesnt
wait for test.wbt to get executed.

Please help me what i m doing wrong also it would be nice if somebody
could explain me why the above program fails and how can I print the
output of the executed programin the current program.

Thanks!!!!!
 
J

Josef Moellers

Hi,
I want to execute some script (May or May not be perl script) from a
perl script and print the output of that executed script.
My Operating system are Windows and Mac OS(Unix).
I was trying the following code without success:


Code
$Response = system("start test.wbt");
print $Response;

By the above code I am able to execute test.wbt but program doesnt
wait for test.wbt to get executed.

Please help me what i m doing wrong also it would be nice if somebody
could explain me why the above program fails and how can I print the
output of the executed programin the current program.

If you ask perldoc what "system" does, it would tell you that "The
return value is the exit status of the program as returned by the "wait"
call."
The same paragraph would then tell you that "This is not what you want
to use to capture the output from a command, for that you should use
merely backticks or "qx//", as described in "`STRING`" in perlop.".

HTH,

Josef
 
J

Jürgen Exner

I want to execute some script (May or May not be perl script) from a
perl script and print the output of that executed script.
$Response = system("start test.wbt");
print $Response;

By the above code I am able to execute test.wbt but program doesnt
wait for test.wbt to get executed.

That can't be. system() will first execute whatever external command you
pass as a parameter. Depending on what arguments you pass to system() it may
or may not use the shell. For details please see the documentation for
system().
And of course it will wait for the external command to terminate, too.
However it has no control over other processes that are launched by the
external command in turn.
Please help me what i m doing wrong also it would be nice if somebody
could explain me why the above program fails and how can I print the
output of the executed programin the current program.

The documentation of system() explains the reason very explicitly, please
see the third paragraph, first and third sentence.

It is also explained in FAQ
"Why can't I get the output of a command with system()?"

jue
 
A

A. Sinan Unur

Code
$Response = system("start test.wbt");
print $Response;

By the above code I am able to execute test.wbt but program doesnt
wait for test.wbt to get executed.

Please help me what i m doing wrong also it would be nice if somebody
could explain me why the above program fails and how can I print the
output of the executed programin the current program.

You are using the system function. The system function does not do what
you want it to do. Wouldn't you first consult the documentation for the
system function:

perldoc -f system

Or, alternatively, you can use the HTML documentation that comes with
ActiveState Perl:

file:///C:/Perl/html/lib/pods/perlfunc.html#alphabetical_listing_of_perl_functions

file:///C:/Perl/html/index.html

Sinan
 
J

Josef Moellers

Hi,
I want to execute some script (May or May not be perl script) from a
perl script and print the output of that executed script.
My Operating system are Windows and Mac OS(Unix).
I was trying the following code without success:


Code
$Response = system("start test.wbt");
print $Response;

By the above code I am able to execute test.wbt but program doesnt
wait for test.wbt to get executed.

Maybe "start" runs "test.wbt" in the background?
 

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
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top