I have two files: server.sh
and client.sh
, the server sends the following text to the client
client.sh
porta_cliente=5678
porta_servidor=8765
nc -l $porta_cliente | sh
server.sh
porta_cliente=5678
porta_servidor=8765
nc $ip $porta_cliente <<-EOF
dialog --stdout --backtitle 'Bem vindo ao SEPA 0.1' --title 'Menu inicial' --menu 'Escolha uma opção:' 0 0 0 \
Cadastrar 'Criar um novo usuário' \
Entrar 'Fazer login com sua conta' \
Sair 'Encerrar o SEPA' > logservidor
# WORKING FINE UNTIL HERE!
case `cat logservidor` in
"Cadastrar")
echo "LOG: case is being executed" > /dev/tcp/"$ip"/"$porta_servidor"
dialog --stdout --msgbox 'CADASTRAR' 0 0 > /dev/tcp/"$ip"/"$porta_servidor"
;;
"Entrar")
echo "LOG: case is being executed"
echo "LOGIN SELECIONADO" > /dev/tcp/"$ip"/"$porta_servidor"
;;
"Sair")
echo "LOG: case is being executed"
echo "SAIR SELECIONADO" > /dev/tcp/"$ip"/"$porta_servidor"
;;
esac
EOF
As you can see, the server sends a text (interpreted as multiple lines of commands) to the client through netcat, on these commands, i'm trying to pass the user input to a specific file, and then, use a case statement to check if that user input is Cadastrar
, Entrar
or Sair
, the first dialog part is working fine, but the case 'cat log servidor' in
is not being executed (even with bash -x server.sh
i couldn´t find what is causing this problem)
bash -x server.sh
won't give any errors as the server only pipes the text to the client. Copy the part between the EOF (the here-doc) and manually insert it on the client. Run it from there and you'll most propably find the error.