Last active
October 27, 2015 02:59
-
-
Save hjzheng/b8c778dbb0c713394de5 to your computer and use it in GitHub Desktop.
用于iTerm2的自动telnet脚本
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 #Where the script should be run from. | |
#If it all goes pear shaped the script will timeout after 20 seconds. | |
set timeout 20 | |
#First argument is assigned to the variable name | |
set name [lindex $argv 0] | |
#Second argument is assigned to the variable user | |
set user [lindex $argv 1] | |
#Third argument is assigned to the variable password | |
set password [lindex $argv 2] | |
#This spawns the telnet program and connects it to the variable name | |
spawn telnet $name | |
#The script expects login | |
expect "Username:" | |
#The script sends the user variable | |
send "$user\n" | |
#The script expects Password | |
expect "Password:" | |
#The script sends the password variable | |
send "$password\n" | |
#This hands control of the keyboard over two you (Nice expect feature!) | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment