Skip to content

Instantly share code, notes, and snippets.

@fiveNinePlusR
Last active August 25, 2018 20:42
Show Gist options
  • Save fiveNinePlusR/317a72102a431c863784d2743ab2d87b to your computer and use it in GitHub Desktop.
Save fiveNinePlusR/317a72102a431c863784d2743ab2d87b to your computer and use it in GitHub Desktop.
require 'open3'
#basic shell command
def run_command(current_command)
Open3.popen2e(current_command) {|stdin, stdout, wait_thr|
pid = wait_thr.pid # pid of the started process.
puts pid
stdout.each do |line| log line end
exit_status = wait_thr.value # Process::Status object returned.
puts "exit status '#{exit_status}'"
return exit_status
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment