This commit is contained in:
Luk Lu
2021-07-18 20:40:10 +08:00
parent b773cc5bcf
commit 98bb2c5681
4 changed files with 12 additions and 10 deletions

19
expect-ssh.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/expect
# Usage: expect this.sh [hostname] [username] [password]
set timeout 30
spawn ssh [lindex $argv 1]@[lindex $argv 0] -p 22
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "[lindex $argv 2]\n";exp_continue}
":~"
{send "su\n";exp_continue}
"Password:"
# {send "[lindex $argv 3]\ncd /faronear\n"}
# "密码:"
{send "[lindex $argv 2]\ncd /faronear\n"}
}
interact