From: ara.t.howard@... Date: 2006-10-06T22:40:18+09:00 Subject: Re: getstatusoutput On Fri, 6 Oct 2006, OliverMarchand wrote: > Dear Ruby fellows, > > I am desperately trying to write a quite simple function (something > similar to what I was acumstomed to with Python) > > status, stdout, stderr = getstatusoutput(somecmdstring) > > status is an integer, stdout and stderr are strings > > Now in principle I know how to write such a function, but I don't know > what the best interface to spawn the process given in somecmdstring is. > Here is my analysis of the situation: > > IO::popen --- mixes stdout and stderr > Open3.popen3 --- no possibility to wait for the process to finish > exec --- I would have to write "everything" by myself, double fork, > etc. > ...popen4 --- not a standard function > > Is my analysis right, or is there something I am not understanding > about open3? your analysis is correct, it's why i wrote open4. however, you cannot wait on the program with 'getstatusoutput' either - at least i don't see the child pid in there? do you mean you just need the exit_status? i assume so given the interface above. the thing with using open4 is that you can also do things like status = spawn 'echo', :stdin => 'foobar' you're free to steal the code too - the liscense is ruby's. otherwise gem install open4 regards. -a -- in order to be effective truth must penetrate like an arrow - and that is likely to hurt. -- wei wu wei