Index: /trunk/DataCheck/Transfer/RsyncRawToISDC.sh
===================================================================
--- /trunk/DataCheck/Transfer/RsyncRawToISDC.sh	(revision 17573)
+++ /trunk/DataCheck/Transfer/RsyncRawToISDC.sh	(revision 17574)
@@ -25,13 +25,33 @@
    runid=${primaries[$s+$s+1]}
    nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
-   
+   lppath="/loc_data/zipraw/"$nightpath
+   nightrun=$night"_"`printf %03d $runid`
+   lpfile=`ssh fact@161.72.93.131 "find $lppath -type f -regex '.*$nightrun[.]fits[.][fg]z'"`
+   if [ "$lpfile" == "" ]
+   then
+      #echo $nightrun" not yet available on data."
+      printprocesslog "INFO "$nightrun" not yet available on data."
+      continue
+   else
+      filename=`basename $lpfile`
+   fi
+
    setstatus "start" 
 
-   rawfilelp="/loc_data/zipraw/./"$nightpath"/"$night"_"`printf %03d $runid`".fits.gz"
+   rawfilelp="/loc_data/zipraw/./"$nightpath"/"$filename
    rawdirisdc="/scratch/from_lapalma/raw/"
-   rawfileisdc=$rawdirisdc$nightpath"/"$night"_"`printf %03d $runid`".fits.gz"
+   rawfileisdc=$rawdirisdc$nightpath"/"$filename
    ingestlinkpath="/scratch/ingest_links/raw/"$nightpath
    makedir $ingestlinkpath >> $logfile 2>&1
-   ingestlink=$ingestlinkpath"/"$night"_"`printf %03d $runid`".fits.gz"
+   ingestlink=$ingestlinkpath"/"$filename
+
+   if ! ssh fact@161.72.93.131 "ls $rawfilelp >/dev/null 2>&1"
+   then
+      #echo $rawfilelp" not yet available on data."
+      printprocesslog "INFO "$rawfilelp" not yet available on data."
+      check="no"
+      setstatus "stop"
+      continue
+   fi
 
    # for new rsync
@@ -74,7 +94,18 @@
    if [ $numdrs -gt 0 ]
    then 
-      drsfilelp="/loc_data/zipraw/./"$nightpath"/"$night"_"`printf %03d $runid`".drs.fits.gz"
-      drsfileisdc=$rawdirisdc$nightpath"/"$night"_"`printf %03d $runid`".drs.fits.gz"
-      drsingestlink=$ingestlinkpath"/"$night"_"`printf %03d $runid`".drs.fits.gz"
+      drsfilelp="/loc_data/zipraw/./"$nightpath"/"$nightrun".drs.fits.gz"
+      drsfileisdc=$rawdirisdc$nightpath"/"$nightrun".drs.fits.gz"
+      drsingestlink=$ingestlinkpath"/"$nightrun".drs.fits.gz"
+
+      if ! ssh fact@161.72.93.131 "ls $drsfilelp >/dev/null 2>&1"
+      then
+         #echo $drsfilelp" not yet available on data."
+         printprocesslog "INFO "$drsfilelp" not yet available on data."
+         check="no"
+         setstatus "stop"
+         continue
+      fi
+
+
       printprocesslog "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc
       echo "INFO rsync drsfile "$drsfilelp" to ISDC "$rawdirisdc >> $logfile 2>&1
