# System() command line args

**URL:** <https://www.ruby-forum.com/t/system-command-line-args/195836>\
**Category:** Ruby\
**Created:** [September 30, 2010, 11:12pm UTC](https://www.ruby-forum.com/t/system-command-line-args/195836 "2010-09-30T23:12:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![larryj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e480ec/32.png) [@larryj](https://www.ruby-forum.com/u/larryj)\
**Post date:** [September 30, 2010, 11:12pm UTC](https://www.ruby-forum.com/t/system-command-line-args/195836/1 "2010-09-30T23:12:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![larryj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e480ec/32.png) [@larryj](https://www.ruby-forum.com/u/larryj)\
**Post date:** [October 1, 2010, 12:07am UTC](https://www.ruby-forum.com/t/system-command-line-args/195836/2 "2010-10-01T00:07:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![larryj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e480ec/32.png) [@larryj](https://www.ruby-forum.com/u/larryj)\
**Post date:** [October 1, 2010, 12:28am UTC](https://www.ruby-forum.com/t/system-command-line-args/195836/3 "2010-10-01T00:28:29Z")

</div>

On Sep 30, 6:13 pm, Larry J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![larryj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e480ec/32.png) [@larryj](https://www.ruby-forum.com/u/larryj)\
**Post date:** [October 1, 2010, 5:56pm UTC](https://www.ruby-forum.com/t/system-command-line-args/195836/4 "2010-10-01T17:56:20Z")

</div>

Luis L. wrote:

> 

Thanks for your response…

the “.exe” makes no difference.

Appears to be a bug.

Larry.

---

<div class="post-metadata">

**Author:** ![larryj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e480ec/32.png) [@larryj](https://www.ruby-forum.com/u/larryj)\
**Post date:** [October 1, 2010, 6:17pm UTC](https://www.ruby-forum.com/t/system-command-line-args/195836/5 "2010-10-01T18:17:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![larryj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e480ec/32.png) [@larryj](https://www.ruby-forum.com/u/larryj)\
**Post date:** [October 2, 2010, 10:38pm UTC](https://www.ruby-forum.com/t/system-command-line-args/195836/6 "2010-10-02T22:38:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![larryj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e480ec/32.png) [@larryj](https://www.ruby-forum.com/u/larryj)\
**Post date:** [October 2, 2010, 10:23am UTC](https://www.ruby-forum.com/t/system-command-line-args/195836/7 "2010-10-02T10:23:57Z")

</div>

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
