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

# runCamera <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:  runCamera Students camera.txt myCam.ppm results.txt
# where:  Students is one directory up, where all the students' directories are
# 			 camera.txt contains the input for the camera
#
# camera.txt is in the student's directory 

if ($#argv < 4) then
   echo ""
   echo "runCamera <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 "./camtest  $xfile  $ofile 2>mycam.log" 
	    		else
	       		echo " *********  file not found:" >> $argv[$#argv]
          	endif
            echo " " >> $argv[$#argv]
      	endif
         echo "done"
         cd ..
      endif
end

