hen*_*hbr 8 shell-script netcat dialog
我有两个文件,client.sh和server.sh. 所有必要的数据都在服务器上,这些数据使用netcat发送到客户端。客户端只是获取这些数据并将其显示给最终用户。问题是,当我尝试显示从服务器到客户端的对话框加载屏幕时:
# CLIENT PORT: 8765
# SERVER PORT: 5678
while :
do
touch registered_users data
nc -vv -l -p 5678 > data
case `cat data` in
"SPLASH_SCREEN")
for ((i=0;i<100;i++))
do
echo $i
done | dialog --title 'Loading...' --gauge 'Welcome!' 8 40 0 > /dev/tcp/127.0.0.1/8765
;;
esac
done
Run Code Online (Sandbox Code Playgroud)
# CLIENT PORT: 8765
# SERVER PORT: 5678
echo "SPLASH_SCREEN" > /dev/tcp/127.0.0.1/5678
while :
do
nc -l -p 8765 > server_response
cat server_response
done
Run Code Online (Sandbox Code Playgroud)
hen*_*hbr 12
解决了!只需要使用 -k 选项
-k Forces nc to stay listening for another connection after its current
connection is completed. It is an error to use this option without the
-l option.
Run Code Online (Sandbox Code Playgroud)