Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Some things I would have never guessed...

by Rhose (Priest)
on Sep 07, 2001 at 17:04 UTC ( #110881=note: print w/replies, xml ) Need Help??

in reply to Re: redirecting STDERR from shell commands
in thread redirecting STDERR from shell commands

I was pretty sure what AidanLee posted above would work correctly, and I would suggest redirecting STDERR as busunsl posted below -- 2>$FILE. What I did *not* know would work was the following code:

Please forgive me, but I only had access to a Windows 2000 PC. *Smiles*

use strict; system("del doesnotexist1"); close(STDERR); open(STDERR,">stderr.out") || die "Could not open STDERR...\n"; system("del doesnotexist2");

This results in "Could Not Find C:\TEMP\doesnotexist1" being displayed on the screen (default for STDERR) and "Could Not Find C:\TEMP\doesnotexist2" being written to stderr.out.

Looks like system() inherits STDERR from the Perl script.

Replies are listed 'Best First'.
Re: Some things I would have never guessed...
by seesik (Initiate) on Sep 07, 2001 at 17:33 UTC
    system() forks, so just like any other forked child process, it inherits any IO handle definitions from the parent process. just fyi.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://110881]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2019-08-21 22:57 GMT
Find Nodes?
    Voting Booth?

    No recent polls found