views:

127

answers:

3

On windows, I can run my ruby script like this:

> ruby myscript.rb

but I want to set things up so that I can just do this instead?..

> myscript.rb

How do I do this? I know it's possible because I've recently moved from one PC that had this set up to a new PC that doesn't (yet).

+4  A: 

Associate the ".rb" file extension with the ruby interpreter. On Windows XP, one way to do this is to select "Tools|Folder options" in the file explorer, and to setup the association in the "File types" tab.

Another way would be to enter the following on the commandline which creates this file association for you:

assoc .rb=RubyScript
ftype RubyScript=ruby.exe %1 %*
Éric Malenfant
If this works, I'd listen to him over me as it sounds like he knows what he's talking about :)
theIV
Damn, that was obvious. (Slaps own face)
izb
A: 

At the head of your script you will need add a sh-bang line such as #!/usr/bin/ruby. I don't know how that works in Windows land, but there must be something.

theIV
It won't. Windows is not UNIX and does not implement exactly the same features. Same goes vice-versa :-)
Joey
I figured as much. Thanks for the heads up.
theIV
A: 

Read the bottom part of Wikipedia Ruby.

Koekiebox