How to fetch output of some other script in the current running perl script?
How to fetch output of some other script in the current running perl script?
am 25.10.2007 14:18:14 von 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!!!!!
Re: How to fetch output of some other script in the current runningperl script?
am 25.10.2007 14:28:32 von Josef Moellers
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:
>=20
>=20
> Code
> $Response =3D system("start test.wbt");
> print $Response;
>=20
> By the above code I am able to execute test.wbt but program doesnt
> wait for test.wbt to get executed.
>=20
> 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=20
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=20
to use to capture the output from a command, for that you should use=20
merely backticks or "qx//", as described in "`STRING`" in perlop.".
HTH,
Josef
--=20
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
Re: How to fetch output of some other script in the current running perl script?
am 25.10.2007 16:40:35 von jurgenex
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
Re: How to fetch output of some other script in the current running perl script?
am 25.10.2007 21:00:50 von 1usa
ritugoyal12@gmail.com wrote in news:1193314694.744816.302990@v29g2000prd.googlegroups.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_lis ting_of_perl_functions
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:
Re: How to fetch output of some other script in the current running perl script?
am 26.10.2007 03:33:54 von Petr Vileta
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;
>
Maybe this help you
$Response = system("start /wait test.wbt");
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Re: How to fetch output of some other script in the current runningperl script?
am 27.10.2007 17:52:40 von Josef Moellers
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.