#!/usr/local/bin/expect #From: Bennett Todd #Cc: libes@cme.nist.gov #Subject: Keen term startup script #Date: Mon, 23 Jan 1995 20:57:07 -0500 (EST) #I just whupped up a pretty slick little script for setting up Term. # #It dials in, passes to an "interact" to let you log in, then sets up term #and finishes up cleanly. I like how straightforward it is. # #Don: Thanks for adding the "-open" option to spawn! Trying to convince #"kermit" to let me do this was extremely ugly! # #-Bennett #bet@mordor.com #!/usr/local/bin/expect set phonenos [list 5551212] log_user 0 spawn -open [open "/dev/modem" "w+"] exec stty 19200 raw /dev/modem set timeout 60 send_user "Logging in now...\r\n" foreach f [set phonenos] { send "ATDP$f\r" expect { CONNECT break -re {BUSY|NO ANSWER} {} } } send_user "hit ^D when you are logged in\r\n" interact "\004" return send_user "\r\n" send "exec term -l tlog\r" system "term -l tlog /dev/modem 2>tlog.err" #>Script looks good except I don't know what Term is!! What is it? #I only recently got around to learning about it. It's much-used in the Linux #community. I think it's one of the sexyest things out there. #Term is a general-purpose serial line handler. If you have a Unix at each #end of a serial line, for interactive use, you want to run term over it. #Very loosely, it is a multiplexer that does error detection and correction, #compression, a sliding window protocol, and so on. There's a term process #running on each end, and their "spigots" are Unix-domain sockets (normally #set up in your home directory). There are clients for login sessions and #file transfers, as well as for tunnling network traffic in different ways. #You can tunnel individual protocols, or have a program (like Mosaic) that #does all it's network interaction through a term connection, or run X #clients remotely and tunnel their connections back to the local server. It's #general-purpose and elegant. It comes with a helper program that explores #the line, and determines which bytes need to be escaped from the protocol. #The upshot of all this is that running term you see file transfers #approaching 99% efficient line utilization, graciously interleaved with #terminal sessions, plus nearly all the benefits of a SLIP connection --- and #everything runs in user mode on both ends, and is easy to set up. Thanks to #expect, it's even easy to automate. #The one thing it doesn't do is terminal emulation for the initial logging #in, to establish the connection. I was doing it by hand, using kermit. I had #a login script that I used with kermit, where expect drove kermit until it #got to the login prompt then turned the session over to me with interact. I #hacked that to return to expect interaction, fire off the remote term, then #(try to!) escape back to the local kermit and fire off the local term. I #couldn't escappe back. I dunno why. Anyway, losing kermit altogether is _so_ #much cleaner!