#!/bin/csh -f

set v_now = `date +'%H%M'`
set v_date = `date`
while ( 0600 < $v_now )
      ls /data/outbound | grep sendfiles > /dev/null
      if ( $status == 0 ) then
         echo $v_date ': Found sendfiles'
	#loop for the files to send
         cd /data/outbound
         foreach datafile (`cat sendfiles`)
            ftp -nv <<EOF
            open null
            user username password
            cd /data/IN
            put $datafile
            quit
EOF
	echo 'Finished processing file'
            mv $datafile archive/$datafile
         end
         rm /data/outbound/sendfiles
      else
	echo $v_date ': FIle not available sleeping for 60 minutes'	
	 sleep 3600 
     endif
   set v_now = `date +'%H%M'`
   end 

exit 0
