defunkt (owner)

Forks

Revisions

gist: 225360 Download_button fork
public
Public Clone URL: git://gist.github.com/225360.git
Embed All Files: show embed
shell_job.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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"