#!/usr/bin/ruby # ruby pseudo terminal emulator # texray@fuckmicrosoft.com # # start the script, then some app # echo "a" > ~/.inputfile will make the app think that you pressed the # 'a' key. The file will automatically be deleted. # This is buggy. I don't know how to fix these bugs. Mail me if you do. # It works for me :> inputfile = "#{ENV['HOME']}/.inputfile" require 'pty' system "stty -echo raw lnext ^_" PTY.spawn("/bin/bash") do |r_pty,w_pty,pid| Thread.new do fork { loop { if File::exist?(inputfile) then w_pty.print File::readlines(inputfile) w_pty.flush File::unlink(inputfile) end sleep(0.3) } } loop { w_pty.print STDIN.getc.chr w_pty.flush } end begin while true c = r_pty.sysread(512) break if c.nil? print c STDOUT.flush end rescue end end system "stty echo -raw lnext ^v"