Friday, October 31, 2008

Ruby scripts (book)

Found out about Basement Books in the Railway Square arcades near Central Station in Sydney.

One on the books I picked up was 'Practical Ruby for Systems Administration' by Andre Ben Hamou (Apress). ISBN-13 978-1-59059-821-4 ISBN-10 1-59059-821-0.

Chapter 2 has a cool beginners script. The first bit on work script in the text.

It's a script to build an empty script and open it in an editor.


#!/usr/bin/env ruby

path = ARGV[0]
fail "specify filename to create" unless path

File.open(path, "w") { |f| f.puts "#!/usr/bin/env ruby" }
File.chmod(0755, path)
system "pico", path


pico is the text editor I use. The example code used "open".

Currently I'm up to chapter 5 and have learn a few thing about Ruby and its what and how.


Gnoll110