linux expect

Install the following software first
yum install -y expect*
yum install -y tcl*

example
#!/usr/bin/expect -f

set ipaddr "172.16.3.3"

set passwd "taovo@123"

spawn ssh taovo@$ipaddr             

expect {

"yes/no" { send "yes\r"; exp_continue}

"password:" { send "$passwd\r" }

}

expect "]#"

send "touch a.txt\r"                     

send "exit\r"

expect eof

exit

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326864957&siteId=291194637