Kashratul has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am aiming to call a perl script from another perl script and re-direct the output of the called script to a text file.

For calling a script from another script -> system "start text.pl"; is working fine.

Individually output of text.pl(called script) can be redirected by => text.pl> text.txt.

But can some one guide me how to redirect the output of the called script(text.pl) by putting some command in the calling script.

Thanks

  • Comment on redirecting the output of the called script thru calling script

Replies are listed 'Best First'.
Re: redirecting the output of the called script thru calling script
by moritz (Cardinal) on Mar 06, 2008 at 10:26 UTC
    system('script.pl > output.txt'); is a "command in the calling script".

    You can also try to do all sorts of magic with filehandles - are you looking for that?

    And what are you trying to achieve in the end? This could be an X Y Problem.

      thanks
Re: redirecting the output of the called script thru calling script
by zentara (Cardinal) on Mar 06, 2008 at 15:36 UTC
    You are looking for IPC (InterProcessCommunication). Read "perldoc perlipc". You have many options..... backticks, piped opens, or my favorite IPC::Open3 ( read perldoc IPC::Open3) and look at this example IPC3 buffer limit problem. A simple bit of code is More examples are out there, just search for them here, or on groups.google.com

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum