[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

pass command line param. to ruby script?

reed.adam@gmail.com

6/26/2006 1:38:00 PM

I'm trying to find out if it's possible, and if so, how to pass a
command line parameter to a ruby script.

The reason for inquiring is that I'd like to have a for loop that runs
a few automated test cases (watir), but I want the user to be able to
specify the variable in the loop without editing the script itself.

Thanks!

6 Answers

Tim Hoolihan

6/26/2006 2:02:00 PM

0


put the following in the file and run it like so: ruby test.rb hello

#test.rb
puts ARGV[0] if ARGV[0]


reed.adam@gmail.com wrote:
> I'm trying to find out if it's possible, and if so, how to pass a
> command line parameter to a ruby script.
>
> The reason for inquiring is that I'd like to have a for loop that runs
> a few automated test cases (watir), but I want the user to be able to
> specify the variable in the loop without editing the script itself.
>
> Thanks!
>

reed.adam@gmail.com

6/26/2006 9:55:00 PM

0

What is that doing exactly? Is ARGV[0] the variable name for the first
parameter after the ruby script name?

Tim Hoolihan wrote:
> put the following in the file and run it like so: ruby test.rb hello
>
> #test.rb
> puts ARGV[0] if ARGV[0]
>
>
> reed.adam@gmail.com wrote:
> > I'm trying to find out if it's possible, and if so, how to pass a
> > command line parameter to a ruby script.
> >
> > The reason for inquiring is that I'd like to have a for loop that runs
> > a few automated test cases (watir), but I want the user to be able to
> > specify the variable in the loop without editing the script itself.
> >
> > Thanks!
> >

mathew

6/26/2006 10:01:00 PM

0

reed.adam@gmail.com wrote:
> I'm trying to find out if it's possible, and if so, how to pass a
> command line parameter to a ruby script.

You'll probably find it helpful to look at
<URL:http://www.ruby-doc.org/stdlib/libdoc/getoptlong/rdoc/inde...
now that I've documented it.


mathew
--
<URL:http://www.pobox.com/...
My parents went to the lost kingdom of Hyrule
and all I got was this lousy triforce.

Gavin Kistner

6/26/2006 10:24:00 PM

0

mathew wrote:
> You'll probably find it helpful to look at
> <URL:http://www.ruby-doc.org/stdlib/libdoc/getoptlong/rdoc/inde...
> now that I've documented it.

See also other useful libraries that do similar things, like Usage:
http://rubyforge.org/proje...

Tim Hoolihan

6/27/2006 4:39:00 PM

0

reed.adam@gmail.com wrote:
> What is that doing exactly? Is ARGV[0] the variable name for the first
> parameter after the ruby script name?
>
> Tim Hoolihan wrote:
>> put the following in the file and run it like so: ruby test.rb hello
>>
>> #test.rb
>> puts ARGV[0] if ARGV[0]

Yes, ARGV is an array of all the command line parameters, with 0 being
the 1st.

So the script is printing your first paramter if it exists.

LC

1/13/2010 10:19:00 PM

0


"John Manning" <jrobertm@terra.com.br> wrote in message
news:EqidnfdG5bnW39PWnZ2dnUVZ_uudnZ2d@giganews.com...
> LC wrote:

>> <vivapadrepio@aol.com> wrote in message
>> news:6df4fdf8-685d-4b04-8765-c59820e55b7f@j5g2000yqm.googlegroups.com...

>>> Remember how an earthquake story used to be something you read about
>>> in a newspaper maybe twice a year? Well, we're reading about
>>> earthquakes twice a month now, at least.

>> So...you'll be rushing right there to help out, faux padre?

>> No, I didn't think so.


> The sadistic sick fuck apparently delights in human misery and death. It's
> another example of his Christian love.

Indeed.
AmUsenet is an excellent venue for letting these fundie fuckwits expose
themselves as the heartless droids they really are.