redirecting stderr not working

Started by Darth_Severus, December 23, 2015, 04:24:27 AM

Previous topic - Next topic

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

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



In file: script

#!/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.



~> ./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

#2
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.