From: Quintus Date: 2010-09-13T05:21:04+09:00 Subject: Re: Wait on external program? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 12.09.2010 19:26, schrieb Larry Jones: > Marvin, > > Thanks for the suggestion; however, I don’t understand how this will > force Ruby to wait until the external process is complete. > > Are you suggesting some sort of while.. loop waiting for the variable to > change? > > The external process is not Ruby code but a windows application. > > Thanks, > Larry The backtick method (yeah, that'a a method, see http://www.ruby-doc.org/ruby-1.9/classes/Kernel.html#M002609 ) executes the command you pass, waits for it to finish and captures the output emmited by the command. I'm on Linux Ubuntu at the moment, but this example should explain it: irb(main):001:0> str = `sleep 2; echo hello` => "hello\n" irb(main):002:0> I use sleep to simulate a long-running operation (well, 2 seconds lasting ;-) ) followed by outputting hello. The "hello" gets captured by the backticks method and I assign it to the variable str. The Kernel#system method is similar to the backticks (it waits for the process to finish as well), but it doesn't capture the output. Vale, Marvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyNNg8ACgkQDYShvwAbcNnQnwCfRqT+YHMXWv/+2sNdItd42lx+ KkIAnjj6OOc6uLH37Q7rZtjKHc7US+dX =tpVH -----END PGP SIGNATURE-----