#!/usr/bin/env python def usage(): print """ %s makes lines with numbers, incrementing startnumber by step until endnumber is reached. If the last argument is omitted, %s does not print the numbers. Usage: $ %s startnumber step string1 endnumber string2 Example: $ %s 1 1 ' part ' 3 ' meas 1[put space here] meas 2[put space here] meas 3 ' Strings need quotes if there is a space inside, or if the string is empty, as "" or ''. All arguments except string2 are required. If step is less than 1, it will be made 1, but other numbers may be negative. Redirect output to file. (c)2004 David Raleigh Arnold under GNU """ % (sys.argv[0], sys.argv[0], sys.argv[0], sys.argv[0]) sys.exit(0) import string, sys, os try: length = len(sys.argv) if length<5: print "Too few arguments." usage() elif length>6: print "Too many arguments." usage() else: stnum = int(sys.argv[1]) step = int(sys.argv[2]) if step<1: step = 1 strone = sys.argv[3] endnum = int(sys.argv[4]) #strtwo = sys.argv[5] while stnum<=endnum: if length==5: print strone if length==6: strtwo = sys.argv[5] print strone + str(stnum) + strtwo stnum = stnum + step except: sys.exit() #print "python errors:" #print sys.exc_type, sys.exc_value