Something like this:
ARGV.each do|a|
puts "Argument: #{a}"
end
then
$ ./test.rb "test1 test2"
or
v1 = ARGV[0]
v2 = ARGV[1]
puts v1 #prints test1
puts v2 #prints test2
More Related Contents:
- How to pass command line arguments to a rake task
- What will give me something like ruby readline with a default value?
- How to write a switch statement in Ruby
- Ruby class instance variable vs. class variable
- Ruby Gem install Json fails on Mavericks and Xcode 5.1 – unknown argument: ‘-multiply_definedsuppress’
- Blocks and yields in Ruby
- Best way to require all files from a directory in ruby?
- What does %w(array) mean?
- “for” vs “each” in Ruby
- How to make a HTTP request using Ruby on Rails?
- Ruby: Inherit code that works with class variables
- Output array to CSV in Ruby
- How do I run a rake task from Capistrano?
- Weird backslash substitution in Ruby
- Ruby Proc Syntax
- Printing the source code of a Ruby block
- Why does Ruby’s ‘gets’ includes the closing newline?
- Ruby multiline block without do end
- Error to install Nokogiri on OSX 10.9 Maverick?
- `&:views_count` in `Post.published.collect(&:views_count)` [duplicate]
- Ruby: Easiest Way to Filter Hash Keys?
- How to assign hash[‘a’][‘b’]= ‘c’ if hash[‘a’] doesn’t exist?
- Why does white-space affect ruby function calls?
- How to preserve request url with nginx proxy_pass
- When to use `require`, `load` or `autoload` in Ruby?
- Natural Language Processing in Ruby [closed]
- How can I get the absolute URL when extracting links using Nokogiri?
- How to turn a string into a method call? [duplicate]
- What is the behavior when using both positional and keyword arguments in Ruby?
- Combine two Arrays into Hash