Windows users:


goto http://www.ruby-lang.org/en/downloads/
Then to the Ruby on Windows section and download and install the One-Click Installer

To run a script


A few scripts can be run simply by clicking on them.

Often scripts want some kind of input or can give useful output. In this case you want to run them from the command line.

To get a command line:


Start -> Run -> type 'cmd' [and press Enter]
To navigate around your directories, you use commands like these:
[To go to your desktop]
cd 'C:\Documents and Settings\UserName\Desktop'

[To move up a directory]
cd ..

[To list files in a directory]
dir

[To run a ruby script]
myscript.rb

[Or you can run it like this]
ruby myscript.rb

[If the script expects an argument (like a filename)]
myscript.rb filename



Ubuntu/Debian users:


To get it:
sudo apt-get install ruby irb ri

Make sure the script is executable:
chmod +x myscript.rb

To run the script:
./myscript.rb
edit post

Comments

0 Response to 'How to run a ruby script'