#!/bin/sh
#
#BUCKMASTER CD-ROM interface for linux - (c) 1998 F5MZN, Olivier Le Cam.
#
#Contact <f5mzn@imaginet.fr> for any bug report.
#

DXNETDIR=/usr/local/dxnet

#Verify the number of arguments
if [ $# != 1 ]
then
	echo "Syntax : SH/BUCK <callsign>"
	exit 9
fi

#Create the input file which includes the callsign to search
echo "$1" > $DXNETDIR/callbook/input

#Create a lock file - the DOS program don't start to search the database
#before this file is present
echo ""   > $DXNETDIR/callbook/lock

#Wait for the output data - the script knows that datas are ready if ./lock
#has been deleted
TIMEOUT="0"
while [ -e $DXNETDIR/callbook/lock ]
do
	sleep 1		#Wait for one second
	TIMEOUT=`expr $TIMEOUT + 1`
	if [ "$TIMEOUT" = "10" ]
	then
		echo "*** timeout error : please contact the sysop."
		exit 9
	fi
done

#print out the result
cat $DXNETDIR/callbook/output

