sudo su admin
SSH 192.168.0.5
Sudo su user1
Tail - 1000/TMP/& lt; MM>/& lt; Dd> The
The exit
The exit
The exit
The MMdd above is the date of the day, I want to through the following command execution sh script
./log. Sh MM dd
Thank you very much!
CodePudding user response:
#!/bin/bash
IP=10.10.1.145
User=test
Password=1
Expect & lt;Set the timeout of 10
Spawn SSH $user @ $IP
Expect {
"Yes/no" {send "yes \ n"; Exp_continue}
"Password" {send "$password \ n"}
}
Expect "from" {send "tail - 1000 & gt;/TMP/$1/$2. The log \ n}
"Expect eof
EOF
About this!
CodePudding user response:
Thank you,I want to add
at you on the basis of theSudo su admin this command, but without success,
The trouble with?
CodePudding user response:
Other spawn SSH $user @ $IP here can not directly use $user account SSHMust be performed after SSH login sudo su $user