From: Matma Rex Date: 2013-01-09T00:02:26+09:00 Subject: Re: Call Windows .exe with arguments On Tue, 08 Jan 2013 11:01:36 +0100, Damián M. González wrote: > Yes, are you sure that the .exe accept arguments? Of course they do. There are two primary ways to call other programs or command from Ruby: either using the backtick syntax (which internally calls Kernel#`) or using Kernel#system. (There is also Kernel#spawn for heavy-duty work, when you need fine-grained control.) These two differ in how they're called and what's the result. Backticks returns the output of the called shell command, and are processed simply in the same way the command would be processed in cmd.exe shell. So to call program1.exe with "a" and "my dog" as arguments, returning its output: `program1.exe a "my dog"` A Kernel#system call returns a truthy value if the call "succeded" (the program returned a 0 exit code), or a falsy one if it failed (syntax error or nonzero return value). It also accepts multiple arguments: if you only provie one, it acts in the same way as backticks (the string is parsed as a comment by the shell). If you provide multiple, arguments will be passed directly to the called program. So to call program1.exe with "a" and "my dog" as arguments, returning whether the call worked correctly or not: system "program1.exe a \"my dog\"" system "program1.exe", "a", "my dog" I greatly advise you to use the second form, as it automatically escapes the arguments - this is especially important if their contents come from the user, as passing them straight to shell could be a security vulnerability. There are more examples in the docs: http://www.ruby-doc.org/core-1.9.3/Kernel.html -- Matma Rex