Created
August 1, 2018 18:04
-
-
Save beugley/2bede66ff3fbe903a14d32d392a5239f to your computer and use it in GitHub Desktop.
Expect script to automate login using password file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
set password [exec cat .pwd] | |
set timeout -1 | |
# Connect to host, enter password | |
spawn ssh -o ServerAliveInterval=5 -o ServerAliveCountMax=1 server-name.com | |
expect { | |
"Password: " {send "$password\r"; exp_continue} | |
"password: " {send "$password\r"; interact} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment