import os i = 0 def fileIncrement(int): stringInt = str(int) while True: if len(stringInt) < 2: stringInt = '0'+stringInt else: return stringInt def main(): i = 0 while i < 100: stringInt = fileIncrement(i) command = 'sbatch preProcessCC.sh '+stringInt print "STARTING SLURM %s" % stringInt print command os.system(command) i = i + 1 os.system('sleep 2') if __name__ == '__main__': main()