Monday, October 20, 2008

Better search script (ruby)

Turns out I can kick off a text based browser from Ruby just fine. The trick is to use sytem("elinks") instead of `elinks`. Here's the Ruby version of my search script (cleaner):


#!/usr/bin/ruby
require 'open-uri'

site = ARGV[0]
query = URI.escape(ARGV[1..-1].join(" "))

case site
when "google": url = "http://www.google.com/search?q=#{query}"
when "wikipedia": url = "http://en.wikipedia.org/wiki/Special\:Search?search=#{query}"
when "torrentz": url = "http://www.torrentz.com/search?q=#{query}"
when "isohunt": url = "http://isohunt.com/torrents/?ihq=#{query}"
when "mininova": url = "http://www.mininova.org/search/?search=#{query}"
end

system("elinks #{url}")

Saturday, October 18, 2008

Setting destination directory for wget

The phrase "destination directory" does not appear in the wget man page. Turns out they call it the "directory prefix":

wget -P ~/dest/dir www.foo.com/myfile.png