From: Robert Klemme Date: 2009-06-18T05:45:08+09:00 Subject: Re: launch external program On 17.06.2009 16:02, Bertram Scharpf wrote: > Am Mittwoch, 17. Jun 2009, 22:22:49 +0900 schrieb Christopher Carver: >> On Wed, Jun 17, 2009 at 8:08 AM, Andrey Demidov wrote: >>> I'm running external programs like this: >>> >>> status = `rdesktop .... &` >>> >>> But my ruby script doesn't work until the external program finished. >>> How can I run an external program asynchronously? >>> >> system("command") Christopher, system does not execute commands asynchronously. >> You cannot save the output, though. > > Yes, you can. Obama? :-) > output = "" > t = Thread.new { output << `somecmd` } > ... > t.alive? or puts "The full output is:", output You can do this as well: t = Thread.new { `somecmd` } ... output = t.value It seems Thread#value is rarely used but it can be of very useful. http://ruby-doc.org/core-1.8.7/classes/Thread.html#M000243 Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/