Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Saturday, February 12, 2005

Ruby As Shell-Scripting Language (and del.icio.us as web-based AvantGo replacement)

The Ruby scripting language lets you execute system commands by simply enclosing them in backticks. This makes Ruby an excellent object-oriented replacement for shell scripts.

Here is a Ruby shell script that downloads your del.icio.us links (for a given tag) to a local directory for sync'ing to your PDA. del.icio.us is currently the hottest web-based bookmarking service -- super-easy-to-use and powerful (e.g. RSS feeds).


puts `del *.html`
puts `del "C:\\Documents and Settings\\Jon\\My Documents\\X30 Storage Card\\Delicious"\\*.html`
`lynx -source "http://del.icio.us/JonathanAquino/read-review-mobile?setcount=100" | grep delLink`.split("\n").each {|line|
line =~ /.*href="(.*)">(.*)<.a>.*/
puts "#{$2}\n#{$1}\n\n"
`lynx -source "#{$1}" > "#{$2.gsub(/[^A-Za-z0-9]/, " ").gsub(/ +/, " ")[0..30]+".html"}"`
}
puts `cp *.html "C:\\Documents and Settings\\Jon\\My Documents\\X30 Storage Card\\Delicious\\"`

0 Comments:

Post a Comment

<< Home