Skip to content

Instantly share code, notes, and snippets.

@eric
Forked from defunkt/shell_job.rb
Created November 5, 2009 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eric/226703 to your computer and use it in GitHub Desktop.
Save eric/226703 to your computer and use it in GitHub Desktop.
require 'open3'
module ShellJob
@queue = :default
def self.perform(*args)
puts "$ #{args.join(' ')}"
Open3.popen3(*args) do |stdin, stdout, stderr|
puts stdout.read.inspect
end
end
end
## Queue it up
# Resque.enqueue(ShellJob, 'which', 'cat')
ShellJob.perform('which', 'cat')
## Output:
# $ which cat
# "/bin/cat\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment