master perl calling slave perl

Discussion in 'Perl Misc' started by Ela, May 4, 2008.

  1. Ela

    Ela Guest

    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?
     
    Ela, May 4, 2008
    #1
    1. Advertising

  2. "Ela" <> 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/
     
    Joost Diepenmaat, May 4, 2008
    #2
    1. Advertising

  3. Ela

    Ela Guest

    > 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
     
    Ela, May 4, 2008
    #3
  4. Ela

    Jo Guest

    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.
     
    Jo, May 4, 2008
    #4
  5. "Ela" <> wrote:
    >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
     
    Jürgen Exner, May 4, 2008
    #5
  6. Ela

    Ela Guest

    "Jo" <> wrote in message
    news:481d8b97$0$14343$4all.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?
     
    Ela, May 4, 2008
    #6
  7. Jim Gibson <> 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

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
     
    Joost Diepenmaat, May 4, 2008
    #7
  8. On 2008-05-04 19:10, Jim Gibson <> wrote:
    > In article <fvkj8m$1pt$>, Ela
    ><> 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
     
    Peter J. Holzer, May 4, 2008
    #8
  9. "Ela" <> 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
     
    Jürgen Exner, May 4, 2008
    #9
  10. Ela

    Uri Guttman Guest

    >>>>> "JG" == Jim Gibson <> 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 ------ -------- 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 ---------
     
    Uri Guttman, May 4, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hari
    Replies:
    1
    Views:
    1,338
    Sandy
    Apr 20, 2004
  2. Replies:
    5
    Views:
    2,094
  3. Богун Дмитрий

    Slave to master auto linking.

    Богун Дмитрий, Nov 14, 2011, in forum: Python
    Replies:
    0
    Views:
    167
    Богун Дмитрий
    Nov 14, 2011
  4. Dan Thomas
    Replies:
    0
    Views:
    286
    Dan Thomas
    Feb 2, 2011
  5. Ylodis
    Replies:
    7
    Views:
    216
    Dennis Lee Bieber
    Aug 31, 2012
Loading...

Share This Page