Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   How to fetch output of some other script in the current running perl script? (http://www.velocityreviews.com/forums/t905087-how-to-fetch-output-of-some-other-script-in-the-current-running-perl-script.html)

ritugoyal12@gmail.com 10-25-2007 12:18 PM

How to fetch output of some other script in the current running perl script?
 
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!!!!!


Josef Moellers 10-25-2007 12:28 PM

Re: How to fetch output of some other script in the current runningperl script?
 
ritugoyal12@gmail.com wrote:
> 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
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html


Jürgen Exner 10-25-2007 02:40 PM

Re: How to fetch output of some other script in the current running perl script?
 
ritugoyal12@gmail.com wrote:
> 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. Sinan Unur 10-25-2007 07:00 PM

Re: How to fetch output of some other script in the current running perl script?
 
ritugoyal12@gmail.com wrote in news:1193314694.744816.302990@v29g2000prd.googlegr oups.com:

> 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_functio ns

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

Sinan


--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>


Josef Moellers 10-27-2007 03:52 PM

Re: How to fetch output of some other script in the current runningperl script?
 
ritugoyal12@gmail.com wrote:
> 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?


--
Mails please to josef dot moellers
and I'm on gmx dot de.


All times are GMT. The time now is 07:43 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.