#!/bin/sh EXPECTS="TCPRESPONSE=" LOG=/var/log/tcpresponder/tcpresponder.log case "$TCPREMOTEIP" in 192.168.0.10) REMHOST=client1 ;; 192.168.0.11) REMHOST=client2 ;; *) echo "$(LANG=C date +'%b %e %T') Connection atempt from invalid host $TCPREMOTEIP" >>$LOG exit 0 ;; esac read -u 0 LINE if [ "${LINE}" = "${LINE#$EXPECTS}" ]; then echo "$(LANG=C date +'%b %e %T') Invalid request string $LINE from $REMHOST" >>$LOG exit 0 fi TCPRESPONSE=${LINE#TCPRESPONSE=} if [ "x$TCPRESPONSE" = "x" ]; then echo "$(LANG=C date +'%b %e %T') Empty string from $REMHOST" >>$LOG exit 1 fi # Here, do whatever you want. Below is a sample procedure. echo "OK, you sent \`$TCPRESPONSE'" RETVAL=$? DATESTR=$(LANG=C date +'%b %e %T') if [ "$RETVAL" = 0 ]; then echo "$DATESTR Received \`$TCPRESPONSE'($REMHOST) success" >>$LOG else echo "$DATESTR Communication with $REMHOST failed" >>$LOG fi exit $RETVAL