Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions




Ruby Programming
Previous Page Home Next Page

Ruby Programs

Finally, you can run a Ruby program from a file as you would any other shell script, Perl program, or Python program. You can simply run Ruby giving the script name as an argument:

% ruby myprog.rb

Or you can use the Unix ``shebang'' notation as the first line of the program file.[If your system supports it, you can avoid hard-coding the path to Ruby in the shebang line by using #!/usr/bin/env ruby, which will search your path for ruby and then execute it.]

#!/usr/local/bin/ruby -w

puts "Hello, World!"

If you make this source file executable (using, for instance, chmod +x myprog.rb), Unix lets you run the file as a program:

% ./myprog.rb
Hello, World!

You can do something similar under Microsoft Windows using file associations.
Ruby Programming
Previous Page Home Next Page

  Published under the terms of the Open Publication License Design by Interspire