Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to fetch output of some other script in the current running perl script?

Reply
Thread Tools

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

 
 
ritugoyal12@gmail.com
Guest
Posts: n/a
 
      10-25-2007
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!!!!!

 
Reply With Quote
 
 
 
 
Josef Moellers
Guest
Posts: n/a
 
      10-25-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      10-25-2007
(E-Mail Removed) 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


 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      10-25-2007
(E-Mail Removed) wrote in news:(E-Mail Removed) 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 <(E-Mail Removed)>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>

 
Reply With Quote
 
Josef Moellers
Guest
Posts: n/a
 
      10-27-2007
(E-Mail Removed) 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.
 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Trouble running Perl script from within a Perl script laredotornado@zipmail.com Perl Misc 4 07-29-2011 01:44 PM
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
Changing perl script bnews-fetch from by Carl Declerck borniac Perl Misc 0 04-18-2004 11:36 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments