Created
January 13, 2011 08:18
-
-
Save igaiga/777573 to your computer and use it in GitHub Desktop.
shell command runner
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
# -*- 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