expect 实现模拟交互
expect安装
apt install expect
server
#! /bin/bash
read -p "username: " username
read -sp "password: " password
echo -en "
" # echo
echo $username, $password
client
#! /usr/bin/expect
spawn ./server.sh
expect "username: "
send "foo
"
expect "password: "
send "bar
"
interact
运行方法
./client.sh