Skip to content

Instantly share code, notes, and snippets.

@padde
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save padde/f00cd4789b8103829ccb to your computer and use it in GitHub Desktop.
Save padde/f00cd4789b8103829ccb to your computer and use it in GitHub Desktop.
require 'open3'
command = 'sh'
Open3.popen2e(command) do |stdin, stdout_and_stderr, wait_thread|
Thread.new do
stdout_and_stderr.each {|l| puts l }
end
stdin.puts 'ls'
stdin.puts 'sleep 1'
stdin.puts 'ls'
stdin.close
wait_thread.value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment