Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created January 13, 2011 08:18
Show Gist options
  • Save igaiga/777573 to your computer and use it in GitHub Desktop.
Save igaiga/777573 to your computer and use it in GitHub Desktop.
shell command runner
# -*- coding: utf-8 -*-
class Command
attr_accessor :command, :status, :out
def initialize(command)
@command = command
self
end
def run
@out = `#{@command} 2>&1`
@status = $?
puts @out
self
end
def status_code
@status.exitstatus
end
def pid
@status.pid
end
# STDOUT と STDERR を分けてとりたい要望がでてきたら実装する
end
#test
# cmd = Command.new('ls;foo').run
# p cmd.status_code
# p cmd.status
# p cmd.pid
# puts "<cmd.out.chomp>"
# puts cmd.out.chomp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment