我正在尝试使用纯粹的bash脚本进行基础TCP客户端通信。我可以使用netcat,因此我迄今为止编写了以下循环:
nc 10.0.0.104 4646 | while read line
do
if [ "$line" == '{"cmd": 1}' ]
then
# Send text back to the TCP server
echo '{"error": 0}'
fi
done
脚本可以成功连接到我正在使用的服务器应用程序,但我很难弄清楚如何将文本发送回netcat进程。