[Linux-users] any 'expect' gurus?
Bruce Marshall
bmarsh
Wed Aug 15 17:09:30 PDT 2007
On Wednesday 15 August 2007, Lonni J Friedman wrote:
> I'm trying to use expect for the first time to automate the
> installation of a '.run' package which lacks a silent or automated
> installation option.
>
> I used autoexpect to generate the expect script. It works fine if I
> run it on a specific system, however trying to run it on any other
> system where the user running the script is not a known variable
> results in strange behavior. The problem appears to be that
> autoexpect captured my shell prompt as part of its content, and since
> that prompt differs from one system (and distro) to another, it no
> longer gets the match its expecting.
>
> The odd thing is that the script still works, except it never exits
> cleanly at the end, and instead hangs until I manually kill it.
>
> The man page talks about an 'exit' directive, but that doesn't seem to
> work for me, when I append it to the end of the expect script. There
> are also a few references to using wildcards, but I don't see how to
> define them. Anyone been down this road before?
Been down it just a few weeks ago.... but never heard of autoexpect so I
didn't use that.
Here's what I ended up with.... probably could be better but once I got it to
work, I went on to other things.
spawn /usr/bin/rsync -auvzr --delete -e "ssh -p 22 -l <userid> "<usual rsync
to and from stuff > "
expect "password:"
set timeout 20
send "xxxxxxpq\r"
set timeout -1
expect eof
It was the expect eof that did the trick for me. Expect will wait until
the command completes.
More information about the Linux-users
mailing list