HOME=/work/leverington/beamprofilemonitor/hitdata/Scripts/Scripts_20161201
mkdir -p $HOME/jobs
JOB_HOME=$HOME/jobs
rm $JOB_HOME/runconvertjob*

cd $JOB_HOME
for i in {1..46}
do
    if  [ $i -gt 19 -a $i -lt 29 ]; then 
	continue
    fi
    
        
	touch $JOB_HOME/runconvertjob$i.sh
	echo "#!/bin/bash" >> $JOB_HOME/runconvertjob$i.sh
	echo ". /local/env.sh" >> $JOB_HOME/runconvertjob$i.sh
	echo ". /cvmfs/lhcb.cern.ch/lib/lhcb/LBSCRIPTS/LBSCRIPTS_v8r1p1/InstallArea/scripts/LbLogin.sh -c x86_64-slc6-gcc48-opt" >> $JOB_HOME/runconvertjob$i.sh
#	echo ". SetupProject.sh Geant4" >> $JOB_HOME/runconvertjob$i.sh
	echo "source /home/lhcb/leverington/.profile" >> $JOB_HOME/runconvertjob$i.sh
        #point to the correct CERN ROOT 
	echo "source /work/leverington/root-install/bin/thisroot.sh" >> $JOB_HOME/runconvertjob$i.sh
        #execute this command
	echo "/work/leverington/beamprofilemonitor/hitdata/Scripts/Scripts_20161201/convert_batch PiN_run$i.csv" >> $JOB_HOME/runconvertjob$i.sh

	

	qsub -l os=slc6 -l ujl=20 -cwd -j yes $JOB_HOME/runconvertjob$i.sh
sleep 1
done
