Page 1 of 1

redirecting stderr not working

Posted: Wed Dec 23, 2015 12:24 pm
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.

Re: redirecting stderr not working

Posted: Wed Dec 23, 2015 3:34 pm
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.

Re: redirecting stderr not working

Posted: Wed Dec 30, 2015 12:20 am
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.