I have a problem with my script. It seems my password is wrong.


set ip [lindex $argv 0]
spawn telnet $ip
set timeout 10
expect "Login:"
send "administrator\r"
expect "Password:"
send "123456"
send "\r"

It says, login incorrect. But it works, when i use cmd on Windows to telnet to my phone, it works with "administrator" and 123456 as password. I don't know why in my script, I could not log on successfully.

I have to use this script to downgrade/upgrade my phones.

  • Your directive /usr/bin/expecct has an extra c in it. That might not be causing the issue, but could you correct it and try? – rahul Feb 13 '15 at 11:15
  • Also, take a look at this link - bash.cyberciti.biz/security/expect-ssh-login-script. The password could be in uppercase or lower case. Try this and see if it helps. – rahul Feb 13 '15 at 11:16
  • My password is only numbers :/ And sorry for the expecct, my bad, in my script it's expect. – Xiuur Feb 13 '15 at 11:20
  • You haven't send \r after your password, plus you have a send with /r instead \r – YoMismo Feb 13 '15 at 11:21
  • What i meant was the prompt could be either "Password:" or "password", can you try replacing the expect "Password:" with expect "?assword:" – rahul Feb 13 '15 at 11:22

I found the answer. I just have to put some


command before

expect "Login:"

Thanks to all.

  • It is possible to select one's own answer as "accepted". Do that. – Kusalananda Jan 1 '17 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.