We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 906bc62 commit dd37cffCopy full SHA for dd37cff
shell/autossh.sh
@@ -1,14 +1,16 @@
1
#!/usr/bin/expect -f
2
3
-set PASSWORD "password\r"
4
-set IP "IP"
+set timeout 15
+set ip [lindex $argv 0]
5
+set PASSWORD "*******"
6
+
7
+spawn /usr/bin/ssh qiaozhou@$ip
8
+expect {
9
+ timeout { send_user "Timeout."; exit 1 }
10
+ "*password:" { send "$PASSWORD\r"; exp_continue }
11
+ "*~]$ " { send "sudo su admin\r"; exp_continue }
12
+ "*Password:" { send "$PASSWORD\r"; exp_continue }
13
+ "*]$ " { }
14
+}
15
-spawn /usr/bin/ssh qiaozhou@$IP
-expect "*password:"
-send "$PASSWORD"
-expect "*~]$ "
-send "sudo su admin\r"
-expect "*Password:"
-expect "*]$ "
16
interact
0 commit comments