From: "StÃ¥le Z.H" Date: 2008-08-02T05:19:06+09:00 Subject: Re: Capturing shell command output and success? On 1 Aug, 21:59, Kyle Schmitt wrote: > On Fri, Aug 1, 2008 at 2:54 PM, Ståle Z.H wrote: > > Not quite sure if I understood you right, but you could probably do > > something like this: > > res = `command`  # note: ` not ' > > > This executes 'command' and stores the output in res. > > Ståle, >         The problem with that is that it doesn't indicate whether the > command succeeded or failed. > >          By the way, %x{ls /tmp} is identical to `ls /tmp`, it's just > easier to read :) > > --Kyle The return value of the program is stored in $? as far as I can see. I tested it on my laptop, and $? was set to 0 when the command succeeded and 1 when it didn't. (Of course, the return value depends on the program, but non-zero is generally considered failure.)