Put a argument into a Ruby script

Hi,

I would like to send a value in a script by using a argument. For
example, that could be my command:

$ ./script.rb Hello world

And that could be my script:

puts "#{$1} #{$2}"

But I have try it and it do not work... Thank you for your help.

···

--
Posted via http://www.ruby-forum.com/.

I believe the ARGV array is what you're looking for. :slight_smile:

--Jeremy

···

On Nov 14, 2007 11:55 AM, Zangief Ief <z4n9ief@gmail.com> wrote:

Hi,

I would like to send a value in a script by using a argument. For
example, that could be my command:

$ ./script.rb Hello world

And that could be my script:

puts "#{$1} #{$2}"

But I have try it and it do not work... Thank you for your help.
--
Posted via http://www.ruby-forum.com/\.

--
http://www.jeremymcanally.com/

My books:
Ruby in Practice

My free Ruby e-book

My blogs:

http://www.rubyinpractice.com/

It's perfect! xD
Thank you Jeremy

···

--
Posted via http://www.ruby-forum.com/.