You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Matthew Blacklow <ma...@ticca.com> on 2001/09/27 01:22:41 UTC

Perl Scripting help

I am writing a script at the moment which among others things creates
another process using the system call.
What I need to do is capture the screen output of this process into a string
variable so that it can latter be manipulaterd. ie. capture the STDOUT.

Any help, suggestions or sample code would be appreciated.

Thanks,
Matthew


Re: Perl Scripting help

Posted by Ray Graham <rg...@lsil.com>.
You'll need to use the backticks instead of the system call.

$output = `command`;

To get each line of the output, you'll need to split off of \n.

-Ray Graham

Re: Perl Scripting help

Posted by Brian Reichert <re...@numachi.com>.
On Thu, Sep 27, 2001 at 09:22:41AM +1000, Matthew Blacklow wrote:
> I am writing a script at the moment which among others things creates
> another process using the system call.
> What I need to do is capture the screen output of this process into a string
> variable so that it can latter be manipulaterd. ie. capture the STDOUT.

This isn't the right forum for this, really, but assuming you mean
STDOUT/STDERR, consider this:

  <http://www.cpan.org/authors/id/R/RE/REICHERT/System2-0.81.tar.gz>

> Any help, suggestions or sample code would be appreciated.
> 
> Thanks,
> Matthew

-- 
Brian 'you Bastard' Reichert		<re...@numachi.com>
37 Crystal Ave. #303			Daytime number: (603) 434-6842
Derry NH 03038-1713 USA			Intel architecture: the left-hand path

Re: Perl Scripting help

Posted by "Ken Y. Clark" <kc...@logsoft.com>.
On Thu, 27 Sep 2001, Matthew Blacklow wrote:

> Date: Thu, 27 Sep 2001 09:22:41 +1000
> From: Matthew Blacklow <ma...@ticca.com>
> To: modperl@apache.org
> Subject: Perl Scripting help
>
> I am writing a script at the moment which among others things creates
> another process using the system call.
> What I need to do is capture the screen output of this process into a string
> variable so that it can latter be manipulaterd. ie. capture the STDOUT.
>
> Any help, suggestions or sample code would be appreciated.
>
> Thanks,
> Matthew

Matthew,

This isn't the right forum for general Perl help.  Generally speaking,
you should only post mod_perl-specific questions.  If your question is
how best to capture STDOUT from an external program from within a
mod_perl program, then I might suggest you examine something like
Apache::SubProcess or just search The Guide
(http://perl.apache.org/guide) or use Google to search the web for
your answer -- all of which is not to say that you couldn't just
backtick your program and capture the output in a scalar.  There's
lots of information on this.  `perldoc perlop` and look for
"backtick," or, again, use Google to look for your answer.  Or
consider posting your question to an audience who will be more likely
to answer your question, like comp.lang.perl.misc.

ky