summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xruby/proc-in-out-in-out.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/ruby/proc-in-out-in-out.rb b/ruby/proc-in-out-in-out.rb
new file mode 100755
index 0000000..645d620
--- /dev/null
+++ b/ruby/proc-in-out-in-out.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+require 'expect'
+require 'open3'
+
+Open3.popen3("/bin/bash") do
+ | input, output, error, wait_thr |
+ input.sync = true
+ output.sync = true
+
+ input.puts "ls /tmp"
+ puts output.expect("\n", 5)
+
+ input.puts "ls /etc"
+ puts output.expect("\n", 5)
+end
+