System() command line args

System command won’t work with arguments.

For example, a simple test in Windows (launch Notepad from ruby…)

command = 'c:\windows\notepad’
arg = “myfile.txt”
system(command, arg)

Remove the arg and Notepad launches fine.
Notepad (or any other program) won’t launch with command line arguments.

Am I missing something?

Larry.

On 9/30/2010 4:13 PM, Larry J. wrote:

Am I missing something?

I can’t explain what the problem is, but if you add .exe to the command
string, it will work. My guess is that the system command is not
properly processing the given arguments to ultimately pass on to the
Win32 CreateProcess call.

BTW, this appears to be fixed in Ruby 1.9.1.

-Jeremy

On Sep 30, 6:13 pm, Larry J. [email protected] wrote:

System command won’t work with arguments.

Please always indicate which version of Ruby are you talking about
(run “ruby -v”)

calling system() with multiple arguments is not candidate of command/
shell expansion, it assumes you know what are you doing.

C:\windows\notepad does not exist… is notepad.exe

You need to include all.

This has changed in Ruby 1.9 but Ruby 1.8 is “broken” or not smart
enough to deal with this. Which brings again the importance of always
tell us which version are you talking about.

Luis L. wrote:

Thanks for your response…

the “.exe” makes no difference.

Appears to be a bug.

Larry.

On 10/01/2010 10:56 AM, Larry J. wrote:

Luis L. wrote:

Thanks for your response…

the “.exe” makes no difference.

What version of Ruby are you using? Send us the results of running ruby
-v. I was running Ruby 1.8.7-p299 in order to find that workaround.

Appears to be a bug.

It’s definitely a bug, and one that is fixed in the 1.9 series. Are you
seeing this under Ruby 1.9?

-Jeremy

Charles R. wrote:

Hi Larry,

You need to let us know what version of Ruby you’re using. Type ruby
-v at the command line and paste the results back here.

Charles

Thanks Charles,

I’m running version 1.8.6

Thanks for catching the bug.

Larry.

Hi Larry,

You need to let us know what version of Ruby you’re using. Type ruby
-v at the command line and paste the results back here.

Charles