0

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

#!/usr/bin/expect

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.

9
  • 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? Commented Feb 13, 2015 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. Commented Feb 13, 2015 at 11:16
  • My password is only numbers :/ And sorry for the expecct, my bad, in my script it's expect. Commented Feb 13, 2015 at 11:20
  • You haven't send \r after your password, plus you have a send with /r instead \r Commented Feb 13, 2015 at 11:21
  • 1
    get expect to give you more info: add exp_internal 1 after the #! line Commented Feb 13, 2015 at 12:13

1 Answer 1

0

I found the answer. I just have to put some

sleep

command before

expect "Login:"

Thanks to all.

1
  • It is possible to select one's own answer as "accepted". Do that. Commented Jan 1, 2017 at 14:34

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.