Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -e
- typeset -g HOST='your_host'
- typeset -g PORT='port_number'
- typeset -g NAME='user'
- typeset -ag PASSWORD=('pass1' 'pass2')
- typeset -g PROMPT='user@'
- typeset -g COMMAND='command A'
- for password in ${PASSWORD[@]}
- do
- expect -c <<EXPECT && break
- set timeout 20
- spawn telnet ${HOST}:${PORT}
- expect Login: { send \"${name}\\r\" }
- expect {
- Password: { send \"${password}\\r\" }
- incorrect { abort }
- }
- expect -re ${PROMPT} { send \"${COMMAND}\\r\"; send \"quit\\r\"; interact }
- EXPECT
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement