Bash script won't stay open in background after running through while
- by jfreak53
I can't get the following bash script to stay open after the first message is received from NC:
#!/bin/bash
port=3333
nc -l $port | while read msg; do notify-send Alert "$msg"; done
After the first message it exits. I want it to stay open and continue monitoring for new messages from NC.
I know that if I launch nc -l port without the while loop it stays open and I can chat away between the two connections even disconnect from the connected host.
I am sending the message using:
echo 'done' | nc IP port