#! /bin/csh -f
# No data file

# runPlane <dir> <input file> <out file> <resultfile>
#             <dir> is the directory containing the assignment submissions
#             <datafile> is the name of data file 
#             <outfile> is the name of the output file 
#             <resutlfile> is the name of the new file to contain 
#                        the results of the executed program
#
# for example:  runPlane Students plane.txt myPln.ppm resultPln.txt
# where:  Students is one directory up, where all the students' directories are
# 			 plane.txt contains the input for the plane
#
# plane.txt is in the student's directory 

if ($#argv < 4) then
   echo ""
   echo "runPlane <directory> <input file> <out file> <result file>"
   echo ""
   exit
endif

cd $1
   set class = *
   foreach student ($class)
      if (-d $student) then
         cd $student
         echo -n "   executing program for $student..."
         echo "--- results for $student ---" > $argv[$#argv]
         echo " " >> $argv[$#argv]
         if ($#argv > 3) then
            set last = $#argv
            set xfile = $2 
            set ofile = $3
	    		if (-f ../$xfile) then
	        		bash -c "./plntest  $xfile  $ofile 2>myPln.log" 
	    		else
	       		echo " *********  file not found:" >> $argv[$#argv]
          	endif
            echo " " >> $argv[$#argv]
      	endif
         echo "done"
         cd ..
      endif
end

