Trying to create a simple netcat responder:
The "server" would be:
$ while true; do { ./secret.sh; } | sudo netcat -k -q -1 -l 123; done
secret.sh
is:
#!/bin/bash
read line
if [ "$line" == "open" ]; then
echo "sesame"
fi
And the client connection:
$ echo "open" | netcat localhost 123
It's not working as expected. What can be changed to make this work?
After reading some feedback elsewhere, the following changes were suggested:
mkfifo /tmp/pipe
while true; do { cat /tmp/pipe | ./secret.sh 2>&1; } | netcat -kv -lp 123 > /tmp/pipe; done
This works, but it only responds with the results from secret.sh
the first time. Subsequent connections with the correct string don't get the expected response. I'm getting closer, however.