File tree 3 files changed +47
-0
lines changed
3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ if [ " $# " -lt 1 ]
3
+ then
4
+ echo " Usage : myssh <Host Name>"
5
+ exit
6
+ fi
7
+
8
+ cmd=" grep ^$1 mysystem.ini"
9
+ sys_info=` $cmd `
10
+ if [ -n $sys_info ]
11
+ then
12
+ sys_ip=" $( cut -d' :' -f2 <<< $sys_info ) "
13
+ user_name=" $( cut -d' :' -f3 <<< $sys_info ) "
14
+ user_password=" $( cut -d' :' -f4 <<< $sys_info ) "
15
+ fi
16
+ if [ -z $sys_ip ]
17
+ then
18
+ echo " IP mising in init file"
19
+ exit
20
+ fi
21
+ if [ -n $user_name ]
22
+ then
23
+ user_name=" root"
24
+ fi
25
+ if [ -n $user_password ]
26
+ then
27
+ user_password=" passw0rd"
28
+ fi
29
+ myssh.exp $sys_ip $user_name $user_password
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/expect
2
+ set sys_ip [lindex $argv 0];
3
+ set sys_user [lindex $argv 1];
4
+ set sys_pass [lindex $argv 2];
5
+ spawn ssh -l $sys_user $sys_ip
6
+ expect {
7
+ "yes/no" {
8
+ send "yes\r"
9
+ exp_continue
10
+ }
11
+ "assword:" {
12
+ send "$sys_pass\r"
13
+ exp_continue
14
+ }
15
+ }
16
+ #expect ":~#"
17
+ interact
Original file line number Diff line number Diff line change
1
+ HOST:IP:USERNAME:PASSWORD
You can’t perform that action at this time.
0 commit comments