[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

How do you run a .rb file in mac?

Dark Lord

1/27/2007 6:22:00 AM

Hello. I created a ruby program in Smultron, but I couldn't figure out
how to run it on a mac. Should I download anything to execute it? I
thought Macs had ruby pre -installed. Thanks.

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

2 Answers

Dark Lord

1/27/2007 8:37:00 AM

0

Nathan Smith wrote:

>>
>>
> Open /Applications/Utilities/Terminal.app and type: ruby file.rb
>
> You could also type irb to get an interactive console.
>
> Nate

Thanks a lot, Nate. It worked. :)

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

Damian Terentyev

1/27/2007 8:50:00 AM

0

Good day!

On Jan 27, 2007, at 10:03, Nathan Smith wrote:

> On 1/27/07, Dark Lord <sauron_the_great004@yahoo.com> wrote:
>>
>> Hello. I created a ruby program in Smultron, but I couldn't figure out
>> how to run it on a mac. Should I download anything to execute it? I
>> thought Macs had ruby pre -installed. Thanks.
>>
>> --
>> Posted via http://www.ruby-....
>>
>>
> Open /Applications/Utilities/Terminal.app and type: ruby file.rb
>
> You could also type irb to get an interactive console.
>
> Nate

You can also add the following line at the very beginning of your ruby
script:

#!/usr/bin/env ruby

and then run the following command in the Terminal.app:

chmod u+x /path/to/your/file.rb

Then you'll be able to invoke the file by its name.

By the way, ruby that comes with OS X is a bit outdated, so it will be
not a bad option to install a fresh version. The simplest approach is
to use MacPorts.

Your sincerely,
Damian/Three-eyed Fish