-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBatchScript.py
More file actions
52 lines (45 loc) · 1.65 KB
/
Copy pathBatchScript.py
File metadata and controls
52 lines (45 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python
# Filename : var.py
import sys, os, getopt
# Default arguments
current = os.getcwd()
def main(num, argv):
oString = ''
try:
opts, args = getopt.getopt(argv,"hn:m:z:p:",["name=","formatMinus=","formatZero=","formatPlus="])
except getopt.GetoptError:
print 'python BatchScript.py ScriptName start stop -n <inputfile> -m <formatMinus> -z <formatZero> -p <formatPlus>'
sys.exit(2)
for opt, arg in opts:
if opt in ("-n", "--name"):
name = arg
oString = oString + ' ' + name
elif opt in ("-m", "--formatMinus"):
iFile = arg
oString = oString + ' ' + iFile
val = num-1
oString = oString % (val)
elif opt in ("-z", "--formatZero"):
iFile = arg
oString = oString + ' ' + iFile
oString = oString % (num)
elif opt in ("-p", "--formatPlus"):
iFile = arg
oString = oString + ' ' + iFile
val = num+1
oString = oString % (val)
return oString
if __name__ == "__main__":
if ( len(sys.argv) < 4):
print 'BatchScript.py ScriptName start stop -n <inputfile> -m <formatMinus> -z <formatZero> -p <formatPlus>'
print 'NOTE: Use %d as regular expression to indicate integer wildcard in strings'
else:
Script = sys.argv[1]
start = int(sys.argv[2])
stop = int(sys.argv[3])
for seg in range(start, stop, 1):
oString = main(seg, sys.argv[4:])
# Define command
Command = "%s%s" % (Script, oString)
print Command
os.system(Command)