1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
module Fission
module Action
class ShellExecutor
# Internal: Create a new ShellExecutor object.
#
# cmd - Command to execute as a String
#
# Examples:
#
# Fission::Action::ShellExecutor.new 'ls /var/log'
#
# Returns a new Fission::Action::ShellExecutor object.
def initialize(cmd)
@cmd = cmd
end
# Internal: Executes the command in the shell. The command will be
# executed using the ruby '`' method.
#
# Examples:
#
# @executor.execute
#
# Returns a Hash with two keys.
# The key 'output' will contain the output from the command.
# The key 'process_status' will conatian a standard ruby Process::Status
# object.
def execute
{ 'output' => `#{@cmd}`, 'process_status' => $? }
end
end
end
end
|