zombieZero
Technical User
I've got an automated telnet and login piece that works fine (prompts for username and then password), but there's another bit in the CLI I need to automate where you alter the login password, and it prompts you to confirm the password before continuing, and therein lies the problem.
I assumed my scripts would be nearly identical, but they don't seem to behave the same way. Here is what it looks like if you were to enter it in manually (the passwords are hidden when you type them in, which I suspect may be part of the problem):
HA-90(su)->set password readO
Please enter new password:
Please re-enter new password:
Password Changed.
HA-90(su)->
My script looks basically like this:
set cmd "set password $name"
send -i $sid $cmd\r
expect {
-i $sid -re "\[Pp]assword:" {
logMsg LOGIN INFO "Received Password Prompt - sending password - ($pwd)"
after 1000
send -i $sid $pwd\r
}
default {
error "Did not get Password prompt"
}
}
expect {
-i $sid -re "\[Pp]assword:" {
logMsg LOGIN INFO "Received Password Confirmation Prompt - sending password - ($pwd)"
after 1000
send -i $sid $pwd\r
}
default {
error "Did not get Password Confirmation prompt"
}
}
What is happening, is that the command is sent down, and it receives the expected 'Please enter new password:' message. It sends the password again at that point, and I get a timeout because it starts trying to match on "".
Here is the results of the debug when I ran it with exp_internal set:
send: sending "set password readO\r" to { exp30 }
expect: does "" (spawn_id exp30) match regular expression "[Pp]assword:"? no
s
expect: does "s" (spawn_id exp30) match regular expression "[Pp]assword:"? no
et password readO
Please enter new password:
expect: does "set password readO\r\nPlease enter new password:" (spawn_id exp30) match regular expression "[Pp]assword:"? yes
expect: set expect_out(0,string) "password:"
expect: set expect_out(spawn_id) "exp30"
expect: set expect_out(buffer) "set password readO\r\nPlease enter new password:"
send: sending "password0\r" to { exp30 }
expect: does "" (spawn_id exp30) match regular expression "[Pp]assword:"? no
expect: timed out
Can anyone explain why this happens?
I assumed my scripts would be nearly identical, but they don't seem to behave the same way. Here is what it looks like if you were to enter it in manually (the passwords are hidden when you type them in, which I suspect may be part of the problem):
HA-90(su)->set password readO
Please enter new password:
Please re-enter new password:
Password Changed.
HA-90(su)->
My script looks basically like this:
set cmd "set password $name"
send -i $sid $cmd\r
expect {
-i $sid -re "\[Pp]assword:" {
logMsg LOGIN INFO "Received Password Prompt - sending password - ($pwd)"
after 1000
send -i $sid $pwd\r
}
default {
error "Did not get Password prompt"
}
}
expect {
-i $sid -re "\[Pp]assword:" {
logMsg LOGIN INFO "Received Password Confirmation Prompt - sending password - ($pwd)"
after 1000
send -i $sid $pwd\r
}
default {
error "Did not get Password Confirmation prompt"
}
}
What is happening, is that the command is sent down, and it receives the expected 'Please enter new password:' message. It sends the password again at that point, and I get a timeout because it starts trying to match on "".
Here is the results of the debug when I ran it with exp_internal set:
send: sending "set password readO\r" to { exp30 }
expect: does "" (spawn_id exp30) match regular expression "[Pp]assword:"? no
s
expect: does "s" (spawn_id exp30) match regular expression "[Pp]assword:"? no
et password readO
Please enter new password:
expect: does "set password readO\r\nPlease enter new password:" (spawn_id exp30) match regular expression "[Pp]assword:"? yes
expect: set expect_out(0,string) "password:"
expect: set expect_out(spawn_id) "exp30"
expect: set expect_out(buffer) "set password readO\r\nPlease enter new password:"
send: sending "password0\r" to { exp30 }
expect: does "" (spawn_id exp30) match regular expression "[Pp]assword:"? no
expect: timed out
Can anyone explain why this happens?