system() command line args

L

Larry Jones

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.
 
J

Jeremy Bopp

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?

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
 
L

Luis Lavena

System command won’t work with arguments.

Please always indicate which version of Ruby are you talking about
(run "ruby -v")
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?

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.
 
L

Larry Jones

Thanks for your response...

the ".exe" makes no difference.

Appears to be a bug.

Larry.
 
J

Jeremy Bopp

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
 
C

Charles Roper

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
 
L

Larry Jones

Charles said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top