#!/bin/sh
#
# Copyright (c) 2003 by Jeremy Kister
# Author: Jeremy Kister <argus-devel at jeremykister.com>
# Date: 2003-Jun-20 04:31 (EDT)
# Function: client to aim.pl: create tmp file for aim.pl to use
# very lame, i know.
#
# take a look at http://www.jeremykister.com
# for hosting/colo/Internet stuff, check out http://www.nntx.net

recipient=$1

if [ ! "$recipient" ] ; then
	echo "syntax error"
	exit 1
fi

echo "recipient: $recipient" > /tmp/aimqueue.$$
while read line ; do
	echo "$line" >> /tmp/aimqueue.$$
done

locked="0";
while [ "$locked" -eq "0" ] ; do
	ln -n /tmp/aimqueue.$$ /tmp/aimqueue
	if [ $? -gt "0" ] ; then
		echo "could not lock: sleeping 2 seconds and trying again.."
		sleep 2
	else
		locked=1
		rm /tmp/aimqueue.$$
	fi
done
