[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

trouble running ruby programs

Hydro_Flame XZ18

6/8/2007 7:46:00 PM

I'm a newbie programmer and I just downloaded ruby today. I must say I'm
impressed with its ease of use, but I have a problem.
When I try to run programs written in ruby, the window for the program
to run in pops up for a moment, but nothing happens and it closes. The
programs are written correctly and saved in the .rb format, and they
show up as ruby files in My Documents.
Can anyone help? I'm running Windows XP if that helps at all.

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

14 Answers

Peter Szinek

6/8/2007 7:55:00 PM

0

> Can anyone help? I'm running Windows XP if that helps at all.

One solution is to run the program from the command line - so fire up a
terminal, and type

ruby my_program.rb

in the directory where my_program.rb is.

One more thing - you need to ensure that ruby is on your path. I did
this a few years ago for the last time, but I vaguely remember that it
can be accessed through properties of my computer and there environment
settings or something like that.

I am sure people on win32 can provide you better help than me, but until
then you can experiment with this :)

Cheers,
Peter
__
http://www.rubyra... :: Ruby and Web2.0 blog
http://s... :: Ruby web scraping framework
http://rubykitch... :: The indexed archive of all things Ruby.


Hydro_Flame XZ18

6/8/2007 8:10:00 PM

0

I tried going to the command prompt, making sure the file was in the
right folder, but when I typed in ruby "ri20min.rb", it just didn't do
anything. And I'm not sure what you're talking about in the My Computer
properties. I looked but there was no environmental anything.

(btway, I'm the same person, but it wouldn't let me reply without
registering)

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

Michael W. Ryder

6/8/2007 8:19:00 PM

0

Jacob Gillie wrote:
> I tried going to the command prompt, making sure the file was in the
> right folder, but when I typed in ruby "ri20min.rb", it just didn't do
> anything. And I'm not sure what you're talking about in the My Computer
> properties. I looked but there was no environmental anything.
>

Have you tried entering the program name without any quotes?
Your path can be accessed by going to Start, Control Panel and then
System. From there select the Advanced tab and the Environment
Variables button. One of the variables in the top window should be
path. Double click on the path variable and scroll through it looking
for something ending with \ruby\bin.

> (btway, I'm the same person, but it wouldn't let me reply without
> registering)
>

Hydro_Flame XZ18

6/8/2007 8:30:00 PM

0

Yeah, I did it eithout the quotes. (I'm not sure why I put them in my
post...)

But anyway, I went to environment variables, checked to make sure the
path was there and that ruby/bin was in it, and put it in the top window
(it was only in the bottom) but it still won't work by clicking or with
command prompt...

Well, I'll keep trying stuff I guess.

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

Hydro_Flame XZ18

6/8/2007 8:32:00 PM

0

By the way, like I said in the first post, the window for the program
opens up, but it closwes a second or two later. The programs work in the
interactive ruby thing, but not as .rb files.


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

Michael W. Ryder

6/8/2007 8:37:00 PM

0

Jacob Gillie wrote:
> Yeah, I did it eithout the quotes. (I'm not sure why I put them in my
> post...)
>
> But anyway, I went to environment variables, checked to make sure the
> path was there and that ruby/bin was in it, and put it in the top window
> (it was only in the bottom) but it still won't work by clicking or with
> command prompt...
>
> Well, I'll keep trying stuff I guess.
>

What do you get if you enter path from a command prompt? Does it show
\bin\ruby?

Hydro_Flame XZ18

6/8/2007 8:46:00 PM

0

No... When I open command prompt it says C:\Documents and
Settings\Jacob>(which is the folder I have the program in)

And then I type

ruby ri20min.rb

and it does nothing.

The bin folder is in c:\ruby\bin, but I really don't know how to go up a
folder.
It might help if I actually knew HOW to use the command prompt... TO THE
HELP MANUAL!!!

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

Hydro_Flame XZ18

6/8/2007 9:03:00 PM

0

Well, I managed to figure out how to get where I want in command prompt
and whatnot, but I still can't run the program...


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

fREW

6/8/2007 9:12:00 PM

0

On 6/8/07, Jacob Gillie <hydroflame@wirelessbeehive.com> wrote:
> No... When I open command prompt it says C:\Documents and
> Settings\Jacob>(which is the folder I have the program in)
>
> And then I type
>
> ruby ri20min.rb
>
> and it does nothing.
>
> The bin folder is in c:\ruby\bin, but I really don't know how to go up a
> folder.
> It might help if I actually knew HOW to use the command prompt... TO THE
> HELP MANUAL!!!
>
> --
> Posted via http://www.ruby-....
>
>

Maybe you should write a super simple ruby program and test with that.
Your program might have no output or something. Try

test.rb
--
#!/usr/bin/ruby

puts "Station!"
--
and do ruby test.rb

if it does nothing after that, then you know it must have something to
do with your commandline.

Also, if you feel like cheating you could either put getc() at the end
of every program (it will wait till you type something to go away.)
or make a wrapper that will do something like:

`ruby #{file}`
getc()

That way your sourcecode is not stuck in Borland C++ mode.

Also, the above code does not work. But there is surely a way to do it.

--
-fREW

Hydro_Flame XZ18

6/8/2007 9:19:00 PM

0

Okay, the program worked in the command prompt, (Station! appeared under
the command line) but I still have the problem with the window closing
before anything appears. Also, there's a premade program in the bin
folder that DOES work in the window... is there some special code I need
to make a program able to open and run by itself?

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