Consider the following netcat command to listen on a port.....
sudo nc -l -u -p 3333 | myscript.sh
contents of myscript.sh is....
#!/bin/sh
while read INPUT; do
echo "Input is $INPUT | tee /tmp/log.$$
done
This waits for a connection on port 3333 and when a connection is made, data sent by the client is piped to myscript.sh for processing. Fine.
So if I use the following command to make a connection to port 3333.....
sudo nc -u 192.168.1.100 3333
and I type some text and hit enter, myscript.sh recieves the string of text. Fine.
But if I kill the client connection by typing Ctrl-C, then the client exits, and if I try to re-establish another client connection again with the same nc command, the server does not establish a new connection. How can my listening "server" re-establish a new connection? I've read a little about the trap command, and thinking that it belongs somewhere to handle interrupts. But where? Or something else to help re-establish another nc command to listen on port 3333?
Thanks for any help.
sudo nc -l -u -p 3333 | myscript.sh
contents of myscript.sh is....
#!/bin/sh
while read INPUT; do
echo "Input is $INPUT | tee /tmp/log.$$
done
This waits for a connection on port 3333 and when a connection is made, data sent by the client is piped to myscript.sh for processing. Fine.
So if I use the following command to make a connection to port 3333.....
sudo nc -u 192.168.1.100 3333
and I type some text and hit enter, myscript.sh recieves the string of text. Fine.
But if I kill the client connection by typing Ctrl-C, then the client exits, and if I try to re-establish another client connection again with the same nc command, the server does not establish a new connection. How can my listening "server" re-establish a new connection? I've read a little about the trap command, and thinking that it belongs somewhere to handle interrupts. But where? Or something else to help re-establish another nc command to listen on port 3333?
Thanks for any help.