#!/bin/bash tmpfile=/tmp/nc-out.$$ ( nc -d -l 127.0.0.1 45000 ) >$tmpfile & echo test | nc 127.0.0.1 45000 wait $! RET="$(cat $tmpfile)" rm $tmpfile if [ "$RET" != "test" ]; then echo "FAIL" exit 1 fi echo "PASS" exit 0