Hello World and More

A simple beginning to Ruby scripting. 

Back to the Ruby Script Library

Our Ruby scripts are all compatible with GoDaddy.com Deluxe hosting. Also see our GoDaddy Ruby Tutorial.

Building your own website has been possible for years with languages such as Perl, or PHP. But now that Ruby has entered the scene, that may start to shift towards Ruby. Although some Ruby interpreters can be slow, Ruby is powerful and flexible, and can be a much better tool for some situations.

To begin with Ruby, make a simple Hello World Script.

#!/usr/local/bin/ruby -w
puts "Content-Type: text/html"
puts
puts "Hello World!

You may now upload this in your server's scripting directory. Some web hosts allow you to name your file (filename).rb, while others may require you to use a .cgi name.

Notice you must put the content type first, otherwise the browser won't know what you're sending it.

Now imagine the world's gotten a lot bigger. You can put on multiple lines with ease!

#!/usr/local/bin/ruby -w
puts "Content-Type: text/html"
puts
puts <<END_OF_STRING
Hello Mandy, Hello Jonathin, Hello Elizibeth, Hello Michelle, Hello Molly, Hello Vicky
Hello Mom, Hello Sister, Hello Joseph, Hello Kristie, Hello Mafia
END_OF_STRING

x