Skip to content

Instantly share code, notes, and snippets.

@simi

simi/wrapper.rb Secret

Created September 15, 2013 12:41
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 simi/bc256154e19366851198 to your computer and use it in GitHub Desktop.
Save simi/bc256154e19366851198 to your computer and use it in GitHub Desktop.
require 'pty'
STDOUT.sync = true
PTY.spawn('./bin/openttd -D -c config.cfg') do |stdin, stdout, pid|
threads = []
threads << Thread.new {
stdin.each {|line| puts "SERVER: #{line}"}
}
threads << Thread.new {
while (command = gets.chomp)
puts "CLIENT: #{command}"
stdout.puts command
end
}
threads.each(&:join)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment