#!/bin/sh

#. /usr/local/bcnu/etc/bcnuenv
. $BCNUHOME/agent/agent_head

#set -x

BCNULOGINT=0	# make sure it's always logged
IFS=":"		# separator is a colon

LOGDATE=`date +%Y%m%d`
LOGFILE="$BCNUHOME/data/$LOGDATE.log"

if [ ! -r "$LOGFILE" ]
then
        echo "$STAMP agent(proxy): $LOGFILE not found"
        exit
fi

$BCNUMESS $LOGFILE >$BCNUTMP/proxy

cat $BCNUTMP/proxy |
{
while read f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12

do

PROXYAGENT=$f5
BCNUAGENT=PROXY$f5		# log it as the correct agent

for param in $BCNUPARAM
do
if [ $f10 -eq 1 ]
   then
	BCNUMSG="$BCNU -h $f3 -m \"$f7\" -e $f2 -t $f12 -f $f11 $param"
   else
	BCNUMSG="$BCNU -h $f3 -m \"$f7\" -e $f2 -t $f12 $param"
fi	

bcnu_send

done

sleep 1

done
}
