# A newbie. not getting run a script

**URL:** <https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517>\
**Category:** ruby-talk\
**Created:** [8 April 2006 13:20 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517 "2006-04-08T13:20:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![san](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@san](https://rubytalk.org/u/san)\
**Post date:** [8 April 2006 13:20 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/1 "2006-04-08T13:20:25Z")

</div>

how to start ruby programming  
installed a irb.

started a tutorial as in following website  
[http://www.crai.archi.fr/RubyLibraryDepot/Ruby/RUBY\_Library\_Depot.htm](http://www.crai.archi.fr/RubyLibraryDepot/Ruby/RUBY_Library_Depot.htm)

in programming chapter it asks to type and save a coding from text  
editor (done) and then to run in a way  
ruby hello.rb

it tried in the console but no result  
i can type line by line in the irb and getting the result

can anyone help???

san

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Meinrad\_Recheis1](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@Meinrad\_Recheis1](https://rubytalk.org/u/Meinrad_Recheis1)\
**Post date:** [8 April 2006 13:42 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/2 "2006-04-08T13:42:38Z")

</div>

if i understand your problem right you expected the script to produce  
the same output as irb when run with ruby. if you want to see the  
result of statements just print them out with p, print or puts.  
hth,  
-- henon

> **···**
>
> On 4/8/06, san \<s\_sasmal@yahoo.com\> wrote:
> 
> > how to start ruby programming  
> > installed a irb.
> > 
> > started a tutorial as in following website  
> > [http://www.crai.archi.fr/RubyLibraryDepot/Ruby/RUBY\_Library\_Depot.htm](http://www.crai.archi.fr/RubyLibraryDepot/Ruby/RUBY_Library_Depot.htm)
> > 
> > in programming chapter it asks to type and save a coding from text  
> > editor (done) and then to run in a way  
> > ruby hello.rb
> > 
> > it tried in the console but no result  
> > i can type line by line in the irb and getting the result
> > 
> > can anyone help???
> > 
> > san

---

<div class="post-metadata">

**Author:** ![san](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@san](https://rubytalk.org/u/san)\
**Post date:** [10 April 2006 11:22 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/3 "2006-04-10T11:22:01Z")

</div>

thanks henon

but actually i have tried with the puts...  
i suppose i am not giving a command to invoke the program. let me  
explain:

i have installed the irb.. somewhere in c:programfiles....  
run irb from start menu  
in text editor i type out a program \*.rb  
now where do i need to save OR  
how do i give a proper path to run the \*.rb file

thanks in advance  
san

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![John9](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@John9](https://rubytalk.org/u/John9)\
**Post date:** [10 April 2006 15:07 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/4 "2006-04-10T15:07:27Z")

</div>

san wrote:

> thanks henon
> 
> but actually i have tried with the puts...  
> i suppose i am not giving a command to invoke the program. let me  
> explain:
> 
> i have installed the irb.. somewhere in c:programfiles....  
> run irb from start menu  
> in text editor i type out a program \*.rb  
> now where do i need to save OR  
> how do i give a proper path to run the \*.rb file
> 
> thanks in advance  
> san

Pass in a -r to either irb or ruby to load that module:

ruby -r yourmodule.rb

or

irb -r yourmodule.rb

Using the ruby command will load it non-interactively, so it'll run just  
like a normal script.

That's if I understand your issue correctly.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Jeff\_Everett](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@Jeff\_Everett](https://rubytalk.org/u/Jeff_Everett)\
**Post date:** [10 April 2006 15:15 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/5 "2006-04-10T15:15:22Z")

</div>

San,

Could you give us a little more information on this, like your system  
info and a listing of the code you're trying to run?

It sounds like you have irb running, so ruby is there somewhere. Try:

ruby -v

just see which version of ruby you have and that it will respond at  
all. Then type your program in Notepad ( I'm guessing your on Windows  
) or some other editor and save it in a file myprogram.rb. Then you  
should be able to:

ruby /path/to/myprogram.rb

And let us know what the result is, error or whatever...

Jeff

> **···**
>
> On 4/10/06, san \<s\_sasmal@yahoo.com\> wrote:
> 
> > thanks henon
> > 
> > but actually i have tried with the puts...  
> > i suppose i am not giving a command to invoke the program. let me  
> > explain:
> > 
> > i have installed the irb.. somewhere in c:programfiles....  
> > run irb from start menu  
> > in text editor i type out a program \*.rb  
> > now where do i need to save OR  
> > how do i give a proper path to run the \*.rb file
> > 
> > thanks in advance  
> > san
> > 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![san](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@san](https://rubytalk.org/u/san)\
**Post date:** [11 April 2006 13:55 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/6 "2006-04-11T13:55:38Z")

</div>

hi thanks all

the version is 1.68.8  
i would try the procedures tonight and be back to you with results

regards  
san

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![san](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@san](https://rubytalk.org/u/san)\
**Post date:** [12 April 2006 05:44 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/7 "2006-04-12T05:44:37Z")

</div>

hi jeff/ john and all others

i have tried all the methods above but in vain  
line by line commands are being executed but i could not run the program  
as a whole

i have a screenshot of the commands. if you can plese look into it and  
give your comments where i am going wrong. the first lines are same as  
that in the file count.rb

since i could not upload image in this forum, i have created a blogger  
[http://santanusasmal.blogspot.com/](http://santanusasmal.blogspot.com/)

regards  
santanu

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Kev\_Jackson2](https://avatars.discourse-cdn.com/v4/letter/k/7ea924/32.png) [@Kev\_Jackson2](https://rubytalk.org/u/Kev_Jackson2)\
**Post date:** [12 April 2006 07:18 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/8 "2006-04-12T07:18:25Z")

</div>

san wrote:

> hi jeff/ john and all others
> 
> i have tried all the methods above but in vain  
> line by line commands are being executed but i could not run the program as a whole
> 
> i have a screenshot of the commands. if you can plese look into it and give your comments where i am going wrong. the first lines are same as that in the file count.rb
> 
> since i could not upload image in this forum, i have created a blogger  
> [http://santanusasmal.blogspot.com/](http://santanusasmal.blogspot.com/)
> 
> regards  
> santanu

you must exit from irb before you can run the command irb -v, similarly with the other commands that refuse to work. irb is the interactive version of ruby, it's not meant for running scripts. to run a script, open a new cmd prompt window and type in something like

ruby my\_script.rb

Good luck  
Kev

---

<div class="post-metadata">

**Author:** ![san](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@san](https://rubytalk.org/u/san)\
**Post date:** [12 April 2006 14:48 UTC](https://rubytalk.org/t/a-newbie-not-getting-run-a-script/26517/9 "2006-04-12T14:48:21Z")

</div>

thanks kev

got the things right this time  
will be back to disturb u all later with many more novice questions:))

san

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
