Advertisement
cd62131

Expect with Incorrect Password

Dec 3rd, 2013
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.51 KB | None | 0 0
  1. #!/bin/bash -e
  2. typeset -g HOST='your_host'
  3. typeset -g PORT='port_number'
  4. typeset -g NAME='user'
  5. typeset -ag PASSWORD=('pass1' 'pass2')
  6. typeset -g PROMPT='user@'
  7. typeset -g COMMAND='command A'
  8. for password in ${PASSWORD[@]}
  9. do
  10.   expect -c <<EXPECT && break
  11. set timeout 20
  12. spawn telnet ${HOST}:${PORT}
  13. expect Login: { send \"${name}\\r\" }
  14. expect {
  15.   Password: { send \"${password}\\r\" }
  16.   incorrect { abort }
  17. }
  18. expect -re ${PROMPT} { send \"${COMMAND}\\r\"; send \"quit\\r\"; interact }
  19. EXPECT
  20. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement