Erlang Mailing Lists

Author Message

<  Erlang  ~  os:cmd() and stdout/stderr behaviour

pommonico
Posted: Wed Nov 25, 2009 7:04 pm Reply with quote
Joined: 25 Nov 2009 Posts: 4
Hello folks. Is os:cmd() supposed to capture both stdout and stderr of the spawned process? The manual seems to indicate stdout only, but my simple test shows otherwise.

If the answer is both, how would I go about suppressing stderr without resorting to tricks like 2>/dev/null?

Confused,
Pom.

Code:
$ cat test_cmd.sh
#!/bin/sh
echo "This goes to stdout"
echo "This goes to stderr" 1>&2

$ ./test_cmd.sh
This goes to stdout
This goes to stderr

$ ./test_cmd.sh  1>/dev/null
This goes to stderr

$ ./test_cmd.sh  2>/dev/null
This goes to stdout

$ erl
Erlang R13B01 (erts-5.7.2) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]
Eshell V5.7.2  (abort with ^G)
1> os:cmd("./test_cmd.sh").
"This goes to stdout\nThis goes to stderr\n"
2>
View user's profile Send private message
uwiger
Posted: Thu Nov 26, 2009 9:45 pm Reply with quote
User Joined: 03 Jul 2006 Posts: 604 Location: Sweden
pommonico wrote:
Hello folks. Is os:cmd() supposed to capture both stdout and stderr of the spawned process? The manual seems to indicate stdout only, but my simple test shows otherwise.

If the answer is both, how would I go about suppressing stderr without resorting to tricks like 2>/dev/null?


Difficult. The os.erl module has this hard-coded:

Code:

-define(SHELL, "/bin/sh -s unix:cmd 2>&1").


So I guess there is no way to tell os:cmd/1 not to do this. You could make your own version...
Confused

_________________
http://www.erlang-consulting.com
View user's profile Send private message Visit poster's website
wuji
Posted: Mon Aug 27, 2012 7:06 am Reply with quote
User Joined: 10 Aug 2012 Posts: 654
if the guy's full of crap or not. You know know [h3]cheap authentic air jordans[/h3] know what I'm saying? Go look in the man's eyes,
you can tell.""He don't forget where he comes from," Maupin Maupin [h4]cheap Ralph Lauren[/h4] Maupin added. "If he does become VP, I can probably
on his door."Bin Laden Anniversary Triggers Law Enforcement SurgeUS Watches Watches cheap authentic jordans Watches for Potential Al Qaeda Plot Against Aviation TargetsBy BRIAN
RICHARD ESPOSITO and RHONDA SCHWARTZApril 26, 2012 — While U.S. U.S. authentic jordans U.S. officials say publicly there is no specific threat of
terror attack, behind the scenes law enforcement officials tell ABC ABC [h2]knockoff designer *beep*[/h2] ABC News there are plans for a major security surge
View user's profile Send private message
dongdongwu
Posted: Thu Sep 20, 2012 2:10 am Reply with quote
User Joined: 19 Sep 2012 Posts: 236
His good friend Diane said: "Christian Louboutin Men Shoes was a magician, he make shoes is immediately put his female people with legs and advantage. He understands women wanted to do and can make them into beautiful Cinderella." Madonna often in its concert wearing Christian louboutin high heels , and some famous superstar like Angelina jolie, mariah Carey, beyonce Knowles, the famous Japanese singer YaYouMei Hamasaki helps Christian Louboutin Men Shoes set up its powerful position. The youngest customers will count Tom cruise's daughter sully cruz. Louboutin made for only a pair of handmade Christian Louboutin high heel Shoes! Want to be more fashion? Put on Christian Louboutin Outlet !
Candy colors of the chalaza high-heeled shoes with lolita type allure, set full finely gem blue "neon shoes" is to need to use "sexy" to describe. Each pair are worth careful appreciation of lithe and graceful fairy ludaoli, what kind of most let you move?Christian Louboutin Men Shoes that one brush red is always cannot resist the temptation, Christian Louboutin men outlet continue to use the days of high 8cm above slender heel proclaim the sexy and luxuriant. The bowknot on black pointed high-heeled shoes with sharp rivet concomitant, wild python met enchanting color printing grain, It is that pairs of high-heeled shoes lets Carrie more feminine flavour. Like Christian Louboutin for men her word.
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum