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