Getting command line

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?

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(’ ')

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

regards.

-a

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

On 9/29/06, [email protected] [email protected] wrote:

Bash Reference Manual
Bash Reference Manual

regards.

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