Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > standard output issue when launching a child script

Reply
Thread Tools

standard output issue when launching a child script

 
 
Sherm Pendley
Guest
Posts: n/a
 
      06-19-2005
"erik" <(E-Mail Removed)> writes:

> sub odie_qa_integration{
> qx(/var/apache/cgi-bin/odie-qa.pl device="$device");
> }
>
> I am running a master script that displays results to standard out. But
> when I launch a child script as shown above, all the output is hidden.


It's not hidden, it's returned from the qx() operator. If you want to
print that, just print it:

print qx(/blah/blah);

Have a look at "perldoc perlop", especially the section titled "Quote
and Quote-like Operators".

sherm--
 
Reply With Quote
 
 
 
 
erik
Guest
Posts: n/a
 
      06-19-2005
sub odie_qa_integration{
qx(/var/apache/cgi-bin/odie-qa.pl device="$device");
}

I am running a master script that displays results to standard out. But
when I launch a child script as shown above, all the output is hidden.
How can I make the output of the child output the same as the parent
script?

 
Reply With Quote
 
 
 
 
erik
Guest
Posts: n/a
 
      06-19-2005
Thanks a million. I was about to explore filehandles before I read
your post.

Thanks again.

 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      06-19-2005
erik wrote:
> sub odie_qa_integration{
> qx(/var/apache/cgi-bin/odie-qa.pl device="$device");
> }
>
> I am running a master script that displays results to standard out.
> But when I launch a child script as shown above, all the output is
> hidden.


Well, no, not exactly. It's more like you are capturing it and then never
ever use it again because you forgot to assign it to a variable in the first
place.
From "perldoc perlop":

qx/STRING/
`STRING`
A string which is (possibly) interpolated and then executed as a
system command with "/bin/sh" or its equivalent. [...]. The
collected standard output of the command is returned; [...]

> How can I make the output of the child output the same as the
> parent script?


If you don't want to capture the output then don't tell Perl to capture it
but use the proper function for that purpose. Details see 'perldoc -f
system'.

jue


 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      06-19-2005
Sherm Pendley wrote:
> "erik" <(E-Mail Removed)> writes:
>
>> sub odie_qa_integration{
>> qx(/var/apache/cgi-bin/odie-qa.pl device="$device");
>> }
>>
>> I am running a master script that displays results to standard out.
>> But when I launch a child script as shown above, all the output is
>> hidden.

>
> It's not hidden, it's returned from the qx() operator. If you want to
> print that, just print it:
>
> print qx(/blah/blah);


Ouch! If you don't want to capture the program output, then don't use a
function that captures it.
system() is a much better solution for the OP than to capture the output and
then print it.

jue


 
Reply With Quote
 
erik
Guest
Posts: n/a
 
      06-25-2005
sub odie_qa_integration{
print "$device";
print qx(/var/apache/cgi-bin/odie-qa.pl device='a.callahan.com');
}

The print function works great. My other issue is that I cannot argv0
to the child script. I have tried double quotes, no quotes, single
quote. Above I put in a static device name to see what happens and it
fails too. The child script says you gave me "" as a device name. So
that is getting lost from parent to child.

 
Reply With Quote
 
erik
Guest
Posts: n/a
 
      06-25-2005
Something else to note, when I use back ticks and run it from CLI,
rather than running the CGI from the browser, it works great.

So this:

sub odie_qa_integration{
print `/var/apache/cgi-bin/odie-qa.pl device=$device`;
}

way of calling the child script works great from CLI. But in the
browser, the child script still says "device not found" meaning the
parent did not pass the $device to it. If I remove $device and put in a
static device name, I get the same thing. So why would the browser
interface not work but CLI does. Why does any variable passed to
odie-qa.pl, via a browser, get lost.

p.s. I also tried system instead of "print qx" and it behaves the same
way.

 
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
Launching, timing, and killing a child EXE process no_suchluck@hotmail.com Java 1 03-26-2009 05:51 PM
getting standard error and output from ruby script in real time Stefano Crocco Ruby 9 06-01-2008 09:29 AM
How to redirect a "system" standard output and standard error to avariable (Linux) Venks Ruby 5 12-06-2007 12:21 AM
Launching pdb from within a script Graham Nicholls Python 8 01-06-2004 01:56 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments