redirecting stderr not working

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?

redirecting stderr not working

Postby Darth_Severus » Wed Dec 23, 2015 12:24 pm

$ 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.
Darth_Severus
 
Posts: 18
Joined: Fri Aug 08, 2014 6:08 pm

Re: redirecting stderr not working

Postby Lutz » Wed Dec 23, 2015 3:34 pm

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.
Lutz
 
Posts: 5258
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: redirecting stderr not working

Postby Darth_Severus » Wed Dec 30, 2015 12:20 am

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.
Darth_Severus
 
Posts: 18
Joined: Fri Aug 08, 2014 6:08 pm


Return to newLISP and the O.S.

Who is online

Users browsing this forum: No registered users and 1 guest

cron