2017-02-04 09:49:06 +03:00
|
|
|
# frozen_string_literal: true
|
1999-08-13 09:37:52 +04:00
|
|
|
require 'pty'
|
|
|
|
|
|
|
|
if ARGV.size == 0 then
|
|
|
|
ofile = "typescript"
|
|
|
|
else
|
|
|
|
ofile = ARGV[0]
|
|
|
|
end
|
|
|
|
|
|
|
|
logfile = File.open(ofile,"a")
|
|
|
|
|
|
|
|
system "stty -echo raw lnext ^_"
|
|
|
|
|
2003-03-07 08:59:42 +03:00
|
|
|
PTY.spawn("/bin/csh") do |r_pty,w_pty,pid|
|
1999-08-13 09:37:52 +04:00
|
|
|
|
|
|
|
Thread.new do
|
|
|
|
while true
|
|
|
|
w_pty.print STDIN.getc.chr
|
|
|
|
w_pty.flush
|
|
|
|
end
|
|
|
|
end
|
2009-03-06 06:56:38 +03:00
|
|
|
|
1999-08-13 09:37:52 +04:00
|
|
|
begin
|
|
|
|
while true
|
1999-08-24 12:21:56 +04:00
|
|
|
c = r_pty.sysread(512)
|
|
|
|
break if c.nil?
|
|
|
|
print c
|
1999-08-13 09:37:52 +04:00
|
|
|
STDOUT.flush
|
1999-08-24 12:21:56 +04:00
|
|
|
logfile.print c
|
1999-08-13 09:37:52 +04:00
|
|
|
end
|
|
|
|
rescue
|
|
|
|
# print $@,':',$!,"\n"
|
|
|
|
logfile.close
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
system "stty echo -raw lnext ^v"
|