File Transfer Over telnet

The ftp program is handy for transferring files but it only works if the remote host is directly reachable via TCP. Suppose you have to telnet to a modem pool and then dial out to another modem to reach the remote host. Not only can ftp not handle this but neither can a lot of other communications programs. In Chapter 16 (p. 346), I presented a file transfer script that used rz and sz. Like many other communications programs, rz and sz require binary copies of their counterpart at each end of the link. If you do not have both, copying one to the other end can be a problem—if it was easy, you would not need the programs in the first place! Even worse, many versions of telnet and other programs do not provide 8-bit clean connections. So even if you had rz and sz, you might not be able to use them over a telnet connection.

The script below works over many kinds of links and does not require a copy of itself on the other end. The only assumptions made are that the usual UNIX utilities (such as cat and compress) exist and that the line is error free. If you do not have compress, that can be removed from the script as well. It is used only to speed the transfers.

The script is quite a bit fancier than the rz/sz script. This one interactively prompts for file names and other commands.

The script starts off by finding out what the prompt looks like. It then disables the default timeout. The script has a verbose mode so that the user can see what is happening internally. ...

Get Exploring Expect now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.