[Chicago-talk] How to subvert error message.

Richard Reina richard at rushlogistics.com
Wed Jul 12 10:02:47 PDT 2006


Thanks for all the great insight.  I think I going to simply redirect the output as Mike suggested.
 
 Thanks again,
 
 Richard

Jonathan Rockway <jon at jrock.us> wrote: It might be more concise/readable to do this:

if(fork()){
    close *STDERR;
    `ls /nonexistent`; # or whatever
}
else {
    print {*STDERR} "stderr still works here\n";
}
wait();
print {*STDERR} "and here\n"

This, BTW, is inconsistent with the description in perldoc ("fds are 
shared", it says).

Regards,
Jonathan Rockway

Jess Balint wrote:
> Richard,
>
> Yet another way is to dup the stderr onto a new fd and then run your
> command. You can restore it afterwards. The following example dups stderr
> onto olderr, then opens stderr onto /dev/null. The command "ls /xxx" is run
> and no error output is displayed. The stderr fd is then restored by duping
> olderr back onto stderr and the command "ls /yyy" is run with the error
> output visible. (It's not the coolest one-liner ;)
>
> perl -e'open(OLDERR, ">&STDERR");open(STDERR, ">/dev/null");system("ls
> /xxx");close(STDERR);open(STDERR, ">&OLDERR");system("ls /yyy");'
>
> ________________________________________
> Hello All,
>
> Is there a way to execute a system command with out the console printing an
> error message?  I wan't to do system("play soundfile.wav") but I do not want
> the error message to print out if the file cannot be played.  
>
> Any help would be greatly appreciated.
>
> Thanks in advance,
>
> Richard
>
>
> Your beliefs become your thoughts. Your thoughts become your words. Your
> words become your actions. Your actions become your habits. Your habits
> become your values. Your values become your destiny. -- Mahatma Gandhi
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>   

_______________________________________________
Chicago-talk mailing list
Chicago-talk at pm.org
http://mail.pm.org/mailman/listinfo/chicago-talk



Your beliefs become your thoughts.  Your thoughts become your words.  Your words become your actions.  Your actions become your habits.  Your habits become your values.  Your values become your destiny.  -- Mahatma Gandhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/chicago-talk/attachments/20060712/2c109423/attachment.html 


More information about the Chicago-talk mailing list