master perl calling slave perl

E

Ela

In slave perl prog, there're some print codes.
However, when the master perl calling the slave one by system(command), the
slave perl print cannot be redirected to STDOUT. how to solve that?
 
J

Joost Diepenmaat

Ela said:
In slave perl prog, there're some print codes.
However, when the master perl calling the slave one by system(command), the
slave perl print cannot be redirected to STDOUT.

What? That's what it already does by default.
how to solve that?

Did you mean something like

system("perl my_other_program.pl > /dev/null") and die;

?
 
E

Ela

Did you mean something like
system("perl my_other_program.pl > /dev/null") and die;

?
This makes STDOUT nothing to print, I guess?

When running the slave prog directly by perl slave.pl, something is printed
onto screen
but perl master.pl (master.pl call salve.pl by system) does not
 
J

Jo

Ela said:
When running the slave prog directly by perl slave.pl, something is
printed onto screen but
perl master.pl (master.pl call salve.pl by > system)
does not

On my system it does.
Maybe you should post a simple example of master.pl and slave.pl
showing when it doesn't.
 
J

Jürgen Exner

Ela said:
In slave perl prog, there're some print codes.
However, when the master perl calling the slave one by system(command), the
slave perl print cannot be redirected to STDOUT. how to solve that?

I cannot reproduce your problem:

C:\tmp>type master.pl
use strict; use warnings;
system 'slave.pl';

C:\tmp>type slave.pl
use strict; use warnings;
print "Slave here\n";

C:\tmp>master.pl
Slave here

Obviously the slave program prints to STDOUT just fine.
Please provide a minimal program that demonstrates your problem.

jue
 
E

Ela

Jo said:
Ela said:

On my system it does.
Maybe you should post a simple example of master.pl and slave.pl
showing when it doesn't.


Oh sorry the perl is called by a master SHELL master.sh but not master
perl...

#!/bin/sh
`perl slave.pl $dirname`

So how to solve?
 
J

Joost Diepenmaat

Jim Gibson said:
Send the output stream from your Perl program to STDOUT:

#!/bin/sh
echo `perl slave.pl $dirname`

or, you know:

#!/bin/sh
perl slave.pl $dirname
 
J

Jürgen Exner

#!/bin/sh
`perl slave.pl $dirname`

Dude, you are _EXPLICITELY_ asking the shell to capture the output of
the subprocess and you wonder why it isn't printed?
So how to solve?

Maybe don't ask the shell to caputure the output?

jue
 
U

Uri Guttman

JG> Send the output stream from your Perl program to STDOUT:

JG> #!/bin/sh
JG> echo `perl slave.pl $dirname`

useless use of echo. just drop the backticks as others have mentioned.

uri
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top