Created
January 14, 2015 23:00
-
-
Save Gabelbombe/85293461e455d20c38b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# Expect login and SU for SSH | |
# Usage ssh_sudo_login.expect <host> <ssh user> <ssh password> <su user> <su password> | |
# CPR : Jd Daniel :: Ehime-ken | |
# MOD : 2015-01-14 @ 14:59:06 | |
# VER : Version 1 | |
set timeout 60 | |
spawn ssh [lindex $argv 1]@[lindex $argv 0] | |
expect "yes/no" { | |
send "yes\r" | |
expect "*?assword" { send "[lindex $argv 2]\r" } | |
} "*?assword" { send "[lindex $argv 2]\r" } | |
expect "# " { send "su - [lindex $argv 3]\r" } | |
expect ": " { send "[lindex $argv 4]\r" } | |
expect "# " { send "ls -ltr\r" } | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment