From: ghorner Date: 2009-11-11T08:25:05+09:00 Subject: Re: Calling a subprocess with specific arguments and capturing its output? On Nov 10, 6:00 pm, Dan Q wrote: > Hi. I haven't written Ruby in a while, and I was wondering if someone > could help with a problem I've never managed to solve. I'm writing a > shell script that takes filenames as its arguments, and calls "du" to > get their size. Because I don't want to have to escape everything > perfectly, I was looking for a function with a syntax that allows > separate arguments, like system("du", "-sh", filename). def backtick(cmd,*args) IO.popen('-') {|f| f ? f.read : exec(cmd,*args)} end backtick 'du', '-sh', filename