standard output issue when launching a child script

S

Sherm Pendley

erik said:
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--
 
E

erik

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?
 
E

erik

Thanks a million. I was about to explore filehandles before I read
your post.

Thanks again.
 
J

Jürgen Exner

erik said:
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
 
J

Jürgen Exner

Sherm said:
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
 
E

erik

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.
 
E

erik

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.
 

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

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top