Forum: Ruby system() command line args

2510ff65ec08b2fcffc1a95cae433e46?d=identicon&s=25 Larry Jones (larryj)
on 2010-09-30 23:12
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.
C5e056d4888f81842e966ff308c03416?d=identicon&s=25 Jeremy Bopp (Guest)
on 2010-10-01 00:07
(Received via mailing list)
On 9/30/2010 4:13 PM, Larry Jones 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
E7cff3cfd41c495e1012227d7dc24202?d=identicon&s=25 Luis Lavena (luislavena)
on 2010-10-01 00:28
(Received via mailing list)
On Sep 30, 6:13 pm, Larry Jones <misterljo...@yahoo.com> 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.
2510ff65ec08b2fcffc1a95cae433e46?d=identicon&s=25 Larry Jones (larryj)
on 2010-10-01 17:56
Luis Lavena wrote:
>
Thanks for your response...

the ".exe" makes no difference.

Appears to be a bug.

Larry.
C5e056d4888f81842e966ff308c03416?d=identicon&s=25 Jeremy Bopp (Guest)
on 2010-10-01 18:17
(Received via mailing list)
On 10/01/2010 10:56 AM, Larry Jones wrote:
> Luis Lavena 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
93fc84c261cdce2e2f1d64c8e531ecb7?d=identicon&s=25 Charles Roper (charlesroper)
on 2010-10-02 10:23
(Received via mailing list)
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
2510ff65ec08b2fcffc1a95cae433e46?d=identicon&s=25 Larry Jones (larryj)
on 2010-10-02 22:38
Charles Roper 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.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.