redirecting stderr not working

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
Darth_Severus
Posts: 18
Joined: Fri Aug 08, 2014 6:08 pm

redirecting stderr not working

Post by Darth_Severus »

$ mocp 2>/dev/null
Running the server...
Trying OSS...

$ mocp &>/dev/null
$

$ newlisp -e "(exec {mocp -i 2>/dev/null})"
()
$

Using (exec {mocp -i 2>/dev/null}) or (exec {mocp -i &>/dev/null}) in a script, I'm getting errors in the bash which is calling the script, even when I call the script with & at the end. Version: newLISP v.10.6.2 32-bit on Linux IPv4/6 UTF-8 libffi.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: redirecting stderr not working

Post by Lutz »

You could try redirecting not to null but to stdout, then let newLISP handle stdout.

In file: script

Code: Select all

#!/usr/bin/env newlisp

(exec "mocp -i 2>&1")

(exit)
now script has no output and the error message is in the return value from exec.

Code: Select all

~> ./script 
~> newlisp -e '(exec "mocp -i 2>&1")'
("sh: mocp: command not found")
~> ./script 
~> 
Ps: just tried your example with (exec "mocp -i 2>/dev/null") in a script and it works fine for me on Linux UBUNTU 14.04, also suppressing error output.

Darth_Severus
Posts: 18
Joined: Fri Aug 08, 2014 6:08 pm

Re: redirecting stderr not working

Post by Darth_Severus »

Many thanks, it works for me now how it should. I think I did something wrong somewhere.
However, the idea with redirecting it to stdout and then using the output in newlisp can be helpfull in other cases. I'm gonna keep that in mind.

Locked