[TriLUG] expect problem

John F. Davis davis at trilug.org
Tue Sep 20 14:01:52 EDT 2005


On Tue, Sep 20, 2005 at 01:51:52PM -0400, Greg Brown wrote:
> Hey peeps.. I seem to have a bug in my expect script. The script changes
> passwords on HP blade servers via telnet. It appears that I am getting an
> extra line back from the server that I was not, um, expecting and it causes
> the script to exit. Here is the section of script I am concered with:
> 
> # look for "accepted"
> expect "*accepted."
> 
> # now look for <hostname>-User Access Control#
> expect "*Control#"
> 
> # send an apply
> send "apply\r"
> 
> # look for the same prompt as before
> expect "*Control#"
> 
> # now tell it to save
> send "save\r"
> 
> # now look for the FLASH prompt
> expect "*[y/n]:"
> 
> # enter a "Y"
> send "Y\r"
> 
> the script fails after "apply" here is captured output (but redirecting
> stdout, nothing was ever sent to stderr):
> 
> - User Access Control# usrpw
> Changing USER password; validation required:
> Enter current administrator password:
> Enter new user password:
> Re-enter new user password:
> New user password accepted.
> 
> >> rtpndsfnth1a8 - User Access Control# apply
> ------------------------------------------------------------------
> Apply complete; don't forget to "save" updated configuration.
> 
> >> xxxxxxxxxxx - User Access Control# spawn telnet xxx.xxx.xxx.252
> Trying xxx.xxx.xxx..252...
> 
> 
> See, that extra "Apply complete" line seem to be throwing me off. The next
> line should be the "Control" prompt I am looking for and I thought that this
> extra line would be processed as I thought it should but it is causing the
> whole script to fail. The script itself is called via a shell script and it
> is only invoked one IP at a time (via the parent shell script).
> 
> Any ideas?

Greg, 

Its been a while since I have done some expect, but why not just throw
in an extra expect apply line which you toss?

JD
> 
> Greg
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> TriLUG PGP Keyring         : http://trilug.org/~chrish/trilug.asc
> 



More information about the TriLUG mailing list