diff options
Diffstat (limited to 'expect/example/telnet-in-bg')
-rw-r--r-- | expect/example/telnet-in-bg | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/expect/example/telnet-in-bg b/expect/example/telnet-in-bg new file mode 100644 index 00000000000..f4edd964caf --- /dev/null +++ b/expect/example/telnet-in-bg @@ -0,0 +1,18 @@ +# Start telnet and when you press ^Z, put telnet in background and save any +# remaining output in "telnet.log". You can actually apply this technique +# to any interactive program - I just chose telnet here. + +# Author: Don Libes, NIST, 1/5/95 + +spawn -ignore HUP telnet $argv ;# start telnet +interact \032 return ;# interact until ^Z + +if [fork] exit ;# disconnect from terminal +disconnect + +set log [open logfile w] ;# open logfile +expect -re .+ { ;# and record everything to it + puts -nonewline $log $expect_out(buffer) + exp_continue +} + |