Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uwm.edu!bionet!agate!ucbvax!hsdndev!husc6!purdue!spaf From: spaf@cs.purdue.EDU (Gene Spafford) Newsgroups: comp.unix.shell Subject: Re: Automated logins and file transfers from a KSh script ? Message-ID: <13401@medusa.cs.purdue.edu> Date: 12 Feb 91 16:01:48 GMT References: <228@nos850.UUCP> Sender: news@cs.purdue.EDU Organization: Department of Computer Science, Purdue University Lines: 35 If you are using a recent version of ksh, I would suggest you try something along the following lines: 1) dispatch the cu process as a co-process, ie: cu -l/dev/ttyAp5 -s2400 |& 2) send it commands with "print -p" 3) Write an "expect" function along the lines of: function expect { typeset pattern="$1" while read -p response do if [[ $response = $pattern ]] then return fi done } 3) Call "expect" with ksh style patterns, like expect "*connected*" The coprocess feature of the ksh is a very powerful way of handling these kinds of situations, but many users don't seem to think to use it. -- Gene Spafford NSF/Purdue/U of Florida Software Engineering Research Center, Dept. of Computer Sciences, Purdue University, W. Lafayette IN 47907-2004 Internet: spaf@cs.purdue.edu phone: (317) 494-7825