Method: LinuxContainer#execute
- Defined in:
- lib/linux_container.rb
#execute(*cmd) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/linux_container.rb', line 128 def execute(*cmd) cmdstring = "#{self.class.sudo_if_needed} #{cmd.shift} #{Shellwords.join(cmd)}" result = '' IO.popen("#{cmdstring} 2>&1", 'r') do |io| io.each_line do |line| yield line if block_given? result << line end end raise "command failed: #{cmdstring.inspect}\n#{result}" unless $? == 0 result end |