Imported Upstream version 5.45
[platform/upstream/expect.git] / example / telnet-in-bg
1 # Start telnet and when you press ^Z, put telnet in background and save any
2 # remaining output in "telnet.log".  You can actually apply this technique
3 # to any interactive program - I just chose telnet here.
4
5 # Author: Don Libes, NIST, 1/5/95
6
7 spawn -ignore HUP telnet $argv          ;# start telnet
8 interact \032 return                    ;# interact until ^Z
9
10 if {[fork]} exit                                ;# disconnect from terminal
11 disconnect
12
13 set log [open logfile w]                ;# open logfile
14 expect -re .+ {                         ;# and record everything to it
15         puts -nonewline $log $expect_out(buffer)
16         exp_continue
17 }
18