expect 实现模拟交互
Posted pkuimyy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了expect 实现模拟交互相关的知识,希望对你有一定的参考价值。
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
以上是关于expect 实现模拟交互的主要内容,如果未能解决你的问题,请参考以下文章