Created
November 3, 2009 19:35
-
-
Save defunkt/225360 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open3' | |
module ShellJob | |
@queue = :default | |
def self.perform(*args) | |
script = args.join(' ') | |
puts "$ #{script}" | |
Open3.popen3(args.join(' ')) 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