[TriLUG] expect problem
Greg Brown
gwbrown1 at gmail.com
Tue Sep 20 13:51:52 EDT 2005
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
More information about the TriLUG
mailing list