Two uses of expect
Yum install expect-y
# install expect first
1. Test usage #! / usr/bin/expect# interpretation language, run here to run with. / run, bash run will report an error spawn ssh root@192.168.0.14# starts a new process expect "* password:" # process receives string, matches send "yxy7714707@\ r" # before matching the content in the input "" expect "* #" send "ifconfig > > 123.txt\ r" send "exit\ r" interact2. Call #! / bin/bash ip=$1# in the sh script to pass the parameter user=$2password=$3expect