Skip to content

Instantly share code, notes, and snippets.

@gronke
Created August 28, 2014 22:38
control-bash-from-ruby
require 'pty'
require 'expect'
str = "RUBY_VERSION"
PTY.spawn("./slave.sh") do |reader, writer|
reader.expect('Hello')
answer = reader.gets
puts "stdout: #{answer}"
sleep 1
writer.puts('Galaxy')
reader.expect('Hello')
answer = reader.gets
puts "stdout: #{answer}"
end
#/bin/bash
echo "Just wanna say Hello World"
read a
echo "And also say Hello to the $a"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment