link https://codingstyle.cn/topics/31
#!/usr/bin/expect
set timeout 30
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "[lindex $argv 3]\n"}
}
interact
這里[lindex $argv 0]
, [lindex $argv 1]
, [lindex $argv 2]
, [lindex $argv 3]
分別代表著4個參數。
將這個文件 item2login.sh
復制到 /usr/local/bin
就可以了。 然后在iTerm2里面配置。
item2login.sh 22 chenyuan 192.168.230.133 chenyuan
腳本 端口號 用戶名 服務器地址 密碼 一定要一一對應