Skip to content

Instantly share code, notes, and snippets.

@wfarr
Created October 22, 2013 23:49
Show Gist options
  • Save wfarr/7110171 to your computer and use it in GitHub Desktop.
Save wfarr/7110171 to your computer and use it in GitHub Desktop.
dirty hacks done right
# cat lol.rb
require "rubygems"
require "json"
output = `/usr/bin/dpkg-query -W --showformat '{ "status": "${Status}", "package": "${Package}", "version": "${Version}" }\n'`.chomp
p JSON.parse("[#{output.split("\n").join(",")}]")[0..2]
# ruby lol.rb
[{"version"=>"1.2.1.30200-1", "status"=>"install ok installed", "package"=>"aacraid"}, {"version"=>"0.6.15-2ubuntu9.6.1", "status"=>"install ok installed", "package"=>"accountsservice"}, {"version"=>"2.2.51-5ubuntu1", "status"=>"install ok installed", "package"=>"acl"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment