#! /bin/bash
p="/tmp/tmpipe"
[ -p $p ] || mkfifo $p
while true; do
echo "*** Starting session..."
tail -f $p | nc -l 4321 | {
while read f; do
f=${f//[^a-zA-Z0-9_.-]/}
case $f in
'') ls > $p ;;
"quit") break ;;
*) [ -f $f ] && cat $f > $p || echo "File Not Found" > $p ;;
esac
done
}
done
---------
> pgrep test-nc.sh
4039
4042