This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.

Controlling MySQL on Unix
def mysql(opts, stream)
  IO.popen("mysql #{opts}", 'w') { |io| io.puts stream }
mysql '-u root -p[password]', <<-end
  drop database if exists website_db;
  create database website_db;
  grant all on website_db.* to #{`id -un`.strip}@localhost;
Errno::EPIPE: Broken pipe
	from (irb):2:in `write'
	from (irb):2:in `mysql'
	from (irb):2:in `mysql'
	from (irb):4