Skip to content

Instantly share code, notes, and snippets.

@zipkid
Created February 15, 2013 09:29
Show Gist options
  • Save zipkid/4959356 to your computer and use it in GitHub Desktop.
Save zipkid/4959356 to your computer and use it in GitHub Desktop.
def execute(command)
debug=false
puts " - Executing: #{command}" if debug
result = {:stdout => [], :stderr => [], :all => []}
Open3.popen3(command) do |stdin, stdout, stderr|
result[:stdout] += stdout.readlines
result[:stderr] += stderr.readlines
result[:all] += result[:stdout] + result[:stderr]
end
if debug
puts result[:all]
else
puts result[:stderr]
end
return result[:all].join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment