Automated logins and file transfers from a KSh script ?
Gene Spafford
spaf at cs.purdue.EDU
Wed Feb 13 03:01:48 AEST 1991
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 at cs.purdue.edu phone: (317) 494-7825
More information about the Comp.unix.shell
mailing list