Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

master perl calling slave perl

0 views
Skip to first unread message

Ela

unread,
May 4, 2008, 2:32:59 AM5/4/08
to
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?


Joost Diepenmaat

unread,
May 4, 2008, 3:04:31 AM5/4/08
to
"Ela" <e...@yantai.org> writes:

> 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;

?

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

Ela

unread,
May 4, 2008, 4:05:04 AM5/4/08
to
> 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


Message has been deleted

Jürgen Exner

unread,
May 4, 2008, 9:37:55 AM5/4/08
to

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

Ela

unread,
May 4, 2008, 11:03:49 AM5/4/08
to

"Jo" <j...@nosp.invalid> wrote in message
news:481d8b97$0$14343$e4fe...@news.xs4all.nl...

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


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?


Lars Eighner

unread,
May 4, 2008, 11:14:44 AM5/4/08
to
In our last episode, <fvkj8m$1pt$1...@ijustice.itsc.cuhk.edu.hk>, the lovely
and talented Ela broadcast on comp.lang.perl.misc:

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

> So how to solve?

Don't use backticks. See man sh.


--
Lars Eighner <http://larseighner.com/> use...@larseighner.com
Countdown: 261 days to go.

Jim Gibson

unread,
May 4, 2008, 3:10:09 PM5/4/08
to
In article <fvkj8m$1pt$1...@ijustice.itsc.cuhk.edu.hk>, Ela
<e...@yantai.org> wrote:

Send the output stream from your Perl program to STDOUT:

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

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com

Joost Diepenmaat

unread,
May 4, 2008, 3:13:33 PM5/4/08
to
Jim Gibson <jimsg...@gmail.com> writes:

> 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ürgen Exner

unread,
May 4, 2008, 3:38:24 PM5/4/08
to
"Ela" <e...@yantai.org> wrote:
>> 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

>#!/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

Peter J. Holzer

unread,
May 4, 2008, 3:37:37 PM5/4/08
to
On 2008-05-04 19:10, Jim Gibson <jimsg...@gmail.com> wrote:
> In article <fvkj8m$1pt$1...@ijustice.itsc.cuhk.edu.hk>, Ela
><e...@yantai.org> wrote:
>> #!/bin/sh
>> `perl slave.pl $dirname`
>>
>> So how to solve?
>
> Send the output stream from your Perl program to STDOUT:
>
> #!/bin/sh
> echo `perl slave.pl $dirname`

Ouch!

hp

Uri Guttman

unread,
May 4, 2008, 4:15:16 PM5/4/08
to
>>>>> "JG" == Jim Gibson <jimsg...@gmail.com> writes:

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

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

--
Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

0 new messages