From: "ara.t.howard" Date: 2008-05-08T01:32:12+09:00 Subject: Re: Getting pipe return codes from SYSTEM command On May 7, 2008, at 9:50 AM, Russell Quinn wrote: > Thanks for the reply. But there is a pipestatus array in bash isn't > there? > > ls | foo > > echo ${PIPESTATUS[0]} > > see: > http://aplawrence.com/Blog/B955.html > > I just couldn't get it to work from Ruby > -- that's because you've lost the bash process by the time bash exits. use my session gem if you want a persistent bash session against which to run commands: require 'session' bash = Session::Bash.new stdout, stderr = bash.execute 'ls | grep something' p bash.status stdout, stderr = bash.execute 'echo ${PIPESTATUS[0]}' p bash.status etc. session uses a *single* bash session for all it's commands so you can do this sort of thing. however i'm not sure what the point is when pipelining from ruby, without shelling out, is so easy? regards. a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama