# Run ruby application with params

**URL:** <https://www.ruby-forum.com/t/run-ruby-application-with-params/112713>\
**Category:** Ruby\
**Created:** [August 22, 2007, 1:35pm UTC](https://www.ruby-forum.com/t/run-ruby-application-with-params/112713 "2007-08-22T13:35:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gugui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9de053/32.png) [@gugui](https://www.ruby-forum.com/u/gugui)\
**Post date:** [August 22, 2007, 1:35pm UTC](https://www.ruby-forum.com/t/run-ruby-application-with-params/112713/1 "2007-08-22T13:35:53Z")

</div>

Hi, i need to run an aplication and send a param with it  
like  
$ ruby application.rb -param\_here

Is it possible ?  
how to receive this param\_here in the ruby application ?

thanks any help

---

<div class="post-metadata">

**Author:** ![gugui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9de053/32.png) [@gugui](https://www.ruby-forum.com/u/gugui)\
**Post date:** [August 22, 2007, 1:49pm UTC](https://www.ruby-forum.com/t/run-ruby-application-with-params/112713/2 "2007-08-22T13:49:50Z")

</div>

> Is it possible ?  
> how to receive this param\_here in the ruby application ?
> 
> ## thanks any help
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

felix@felix-laptop:~$ cat test.rb  
require ‘pp’  
pp ARGV  
felix@felix-laptop:~$ ruby test.rb blah1 blah2  
[“blah1”, “blah2”]  
felix@felix-laptop:~$

There are also the GetOptLong and OptionParser standard libraries.

HTH,

Felix

---

<div class="post-metadata">

**Author:** ![gugui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9de053/32.png) [@gugui](https://www.ruby-forum.com/u/gugui)\
**Post date:** [August 22, 2007, 2:41pm UTC](https://www.ruby-forum.com/t/run-ruby-application-with-params/112713/3 "2007-08-22T14:41:14Z")

</div>

Luiz M. a écrit :

> Hi, i need to run an aplication and send a param with it  
> like  
> $ ruby application.rb -param\_here
> 
> Is it possible ?  
> how to receive this param\_here in the ruby application ?
> 
> thanks any help  
> Hi,

You can use CmdParse or OptionParser gems

---

<div class="post-metadata">

**Author:** ![gugui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9de053/32.png) [@gugui](https://www.ruby-forum.com/u/gugui)\
**Post date:** [August 22, 2007, 9:54pm UTC](https://www.ruby-forum.com/t/run-ruby-application-with-params/112713/4 "2007-08-22T21:54:17Z")

</div>

On Aug 22, 6:35 am, Luiz M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi, i need to run an aplication and send a param with it  
> like  
> $ ruby application.rb -param\_here
> 
> Is it possible ?  
> how to receive this param\_here in the ruby application ?
> 
> ## thanks any help
> 
> Posted viahttp://www.ruby-forum.com/.

$ ruby temp.rb fee fi fo fum  
[“fee”, “fi”, “fo”, “fum”]

And the file temp.rb has  
p ARGV

---

<div class="post-metadata">

**Author:** ![gugui](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9de053/32.png) [@gugui](https://www.ruby-forum.com/u/gugui)\
**Post date:** [August 22, 2007, 5:26pm UTC](https://www.ruby-forum.com/t/run-ruby-application-with-params/112713/5 "2007-08-22T17:26:42Z")

</div>

2007/8/22, Stephane W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> You can use CmdParse or OptionParser gems

OptionParser is not a gem AFAIK - it’s part of the std lib.

robert
