Hi,

some alternative approaches would be:

my $res = `$cmd`; # note that it's not "'" but "`"
# $res only stdout, this will puke out stderr 

or

my $res = `$cmd 2>&1`; # redirect stderr to stdout 
# $res is now both stderr and stdout

or 

my $res = `$cmd 2>/dev/null`; # throw away stderr
# $res is only stdout and no errors shown

/Jon


insomniak wrote:
> 
> Hi,
> You can always write STDERR and STDOUT to a temp file then read the contents
> of this file back in to your script.
> 
> eg
> system (some_command 1>.stdout 2>.stder);
>   STDOUT is written to .stdout
>   STDERR is written to .stderr
> 
> Theres is probably a better way than this but I find this the easiest.
> Anyone else have any comments?
> 
> regards
> Mark Kneen
> 
> ----- Original Message -----
> From: "Matthew Blacklow" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, September 27, 2001 12:44 AM
> Subject: Capturing STDOUT of system launched process
> 
> > 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
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to