From: Mike Wilson Date: 2002-03-07T22:52:09+09:00 Subject: pty and vi I've hacked together a little script, using some of the samples from the ruby distribution. It's using the pty module, but I can't figure out how to get this to work with vi. Whenever I try to vi a file, it basically just overwrites the contents of the file with the vi commands. here's the script: require 'pty' puts "Choose a system to connet to: " puts " 1) t..." puts " 2) a..." puts " 3) h..." puts " 4) d..." puts print "selection(1-4): " sys = STDIN.gets.chomp connect_string = "FFFX30*hmc1*9734*" + sys + "*7040-681*0207D5A*1\n" system "stty -echo raw lnext ^_" PTY.spawn("telnet hmc1 9735") do |r_pty,w_pty,pid| w_pty.print connect_string w_pty.flush Thread.new do while true w_pty.print STDIN.getc.chr w_pty.flush end end begin while true c = r_pty.sysread(512) break if c.nil? print c STDOUT.flush end rescue print $@,':',$!,"\n" end end system "stty echo -raw lnext ^v" _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com