# Getting command line

**URL:** <https://www.ruby-forum.com/t/getting-command-line/70557>\
**Category:** Ruby\
**Created:** [September 30, 2006, 2:42am UTC](https://www.ruby-forum.com/t/getting-command-line/70557 "2006-09-30T02:42:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 30, 2006, 2:42am UTC](https://www.ruby-forum.com/t/getting-command-line/70557/1 "2006-09-30T02:42:52Z")

</div>

Hi,

If I launch a Ruby process with:  
ruby something.rb lots of “stuff here” and I want all ‘of it’

How can I get a string from inside the ruby process with:  
lots of “stuff here” and I want all ‘of it’  
in it?

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 30, 2006, 2:54am UTC](https://www.ruby-forum.com/t/getting-command-line/70557/2 "2006-09-30T02:54:53Z")

</div>

Joe Van D. wrote:

> Hi,
> 
> If I launch a Ruby process with:  
> ruby something.rb lots of “stuff here” and I want all ‘of it’
> 
> How can I get a string from inside the ruby process with:  
> lots of “stuff here” and I want all ‘of it’  
> in it?

ARGV is an array of the tokens on the command line that follow the name  
of the script. If you want them all in one string you can use the join  
method to join them together.

puts ARGV.join(’ ')

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 30, 2006, 4:53am UTC](https://www.ruby-forum.com/t/getting-command-line/70557/3 "2006-09-30T04:53:00Z")

</div>

On Sat, 30 Sep 2006, Joe Van D. wrote:

> Hi,
> 
> If I launch a Ruby process with:  
> ruby something.rb lots of “stuff here” and I want all ‘of it’
> 
> How can I get a string from inside the ruby process with:  
> lots of “stuff here” and I want all ‘of it’  
> in it?

you can’t. the " and ’ are handled by the shell.

ARGV.join will give you

[“lots”, “of” “stuff here”, “and”, “I”, “want”, “all”, “of it”]

note - the quotes will be lost.

read up on bash ‘word splitting’ and ‘quote removal’ for more info

> **[Bash Reference Manual](http://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html)**
>
> Bash Reference Manual

> **[Bash Reference Manual](http://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html)**
>
> Bash Reference Manual

regards.

-a

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [September 30, 2006, 5:53am UTC](https://www.ruby-forum.com/t/getting-command-line/70557/4 "2006-09-30T05:53:40Z")

</div>

Timothy H. wrote:

> > 
> 
> ARGV is an array of the tokens on the command line that follow the name  
> of the script. If you want them all in one string you can use the join  
> method to join them together.
> 
> puts ARGV.join(’ ')

Of course, if you (the OP) want the quotes, you’ll have to escape  
them or the shell will strip them.

Hal

---

<div class="post-metadata">

**Author:** ![joe-dumoulin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9dc877/32.png) [@joe-dumoulin](https://www.ruby-forum.com/u/joe-dumoulin)\
**Post date:** [October 2, 2006, 6:27pm UTC](https://www.ruby-forum.com/t/getting-command-line/70557/5 "2006-10-02T18:27:25Z")

</div>

On 9/29/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [Bash Reference Manual](http://www.gnu.org/software/bash/manual/bashref.html#SEC36)  
> [Bash Reference Manual](http://www.gnu.org/software/bash/manual/bashref.html)
> 
> regards.

Oh yeah, I forgot that the shell automatically escapes stuff. Thanks.
