I have two files, client.sh
and server.sh
, all the necessary data is on the server, which is sent to the client using netcat, the client just get these data and display it to the end user, the problem is when the server send some multiline code, the client just receive it as text and display on screen
client.sh
ip=127.0.0.1
client_port=5678
server_port=8765
while :
do
# Request the menu from the server
echo menu > /dev/tcp/"$ip"/"$server_port"
# Waits the server response
nc -l $porta_cliente
done
server.sh
ip=127.0.0.1
porta_cliente=5678
porta_servidor=8765
while :
do
nc -vv -l $porta_servidor > logservidor
echo "Texto recebido: "`cat logservidor` # LOG
case `cat logservidor` in
"splash")
echo "dialog --stdout --msgbox 'SPLASH' 0 0" > /dev/tcp/"$ip"/"$porta_c$
;;
"menu_inicial")
nc $ip $porta_cliente <<-EOF
dialog --stdout --backtitle 'Bem vindo ao SEPA 0.1' --title 'Me$
Cadastrar 'Criar um novo usuário' \
Entrar 'Fazer login com sua conta' \
Sair 'Encerrar o SEPA'
# Caso o usuário selecione Cancelar, a execução do script será $
if [ $? -eq 0 ]; then
echo SUCESSO
else
rm resposta_servidor dados_digitados 2> /dev/null
clear
exit
fi
EOF
;;
"menu_principal")
echo "dialog --msgbox 'MENU_PRINCIPAL' 0 0" > /dev/tcp/"$ip"/"$porta_cl$
;;
*)
dialog --msgbox 'WTF?!' 0 0 > /dev/tcp/"$ip"/"$porta_cliente"
;;
esac
done