Ruby for Admins is designed to be a source of information and inspiration for all Sysadmins, DBAs, Application Administrators, who are tired and bored scripting with XX century, ancient languages, tools and shells, and who want to learn to use modern programming languages and techniques. If you already know Ruby, you might find here an inspiration for using it in your daily work. If you don't know it yet, you'll be able to learn the basics here - but only the basics, do not expect full Ruby course.
Last read:
Introduction
New chapters:
Lambda Functions (almost 6 years ago)
Config files (almost 6 years ago)
Passing Arguments to Script (over 6 years ago)
Background Jobs (over 6 years ago)
The format of this webpage is blog-o-book, which is not exactly a blog nor a book. You can browse and read it as a book, starting with the Chapter One or read it as a blog, browsing the articles, adding a comments (keep an eye on this symbol), linking to selected paragraphs. It is all up to you. And last but not least, it is free!
Go to the First Chapter
Teaser
#!/bin/bash sids_and_serials=`sqlplus -L -S $1/$2@$3 << EOF set feed off set head off set pages 0 set line 1300 set termout off select sid || ',' || serial# from v\\$session where status='ACTIVE'; exit EOF` ret_code=$? if [ "$ret_code" -ne 0 ]; then echo "Can't connect to the database!" else for s in $sids_and_serials; do echo "alter system kill session '$s';"; done fi
In Ruby, the same script would look like this:
#!/usr/bin/env ruby require 'oci8' dbconnection = OCI8.new(ARGV[0], ARGV[1], dbname=ARGV[2]) dbconnection.exec("select sid, serial# from v$session where status='ACTIVE'") do |row| puts "alter system kill session '#{row[0].to_i}, #{row[1].to_i}';" end
Author
This book is written by Tomek 'Grych' Gryszkiewicz. Do not hestitate to contact me at grych@tg.pl, check my page or just add a comment here:
©2014 Tomek Gryszkiewicz. All rights reserved.