From: Dan Q Date: 2009-11-11T08:00:43+09:00 Subject: Calling a subprocess with specific arguments and capturing its output? 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). system() doesn't allow me to capture the output of the subprocess, while popen , ``, and %x() don't let me specify a list of discrete arguments. Is there an elegant solution to this problem? My current solution is to just escape the arguments and put them into a string, but this is ugly and buggy. Thanks in advance! -Dan