import os, commands import random total_number_of_events = 20000 events_per_job = 200 number_of_job = total_number_of_events/events_per_job first_job = 103 job_index = 0 first_event = 1 for job_index in xrange(number_of_job): inFile = "file_%i.root"%(first_job+job_index) PU_seed = int(random.random()*pow(10,7)) cmd = "qsub test.sh %i %i %s %i" %(events_per_job,first_event,inFile,PU_seed) print cmd os.system(cmd) first_event = first_event+events_per_job