[Chicago-talk] How to subvert error message.

Jess Balint jbalint at gmail.com
Wed Jul 12 08:21:57 PDT 2006


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



More information about the Chicago-talk mailing list