QUOTE(cronos4d @ 30 Jun, 2008 - 06:44 PM)

I have the following code
CODE
if sys.argv[4] == 'state':
try:
print(sys.argv[5])
except:
print "Error gathering server state ", sys.argv[5]
I invoke the python program with myscript.py option1, 2, 3, etc
The fifth argument is a server with a numeric range:
server1,server2,server3, etc.
Instead of wrapping the script, I would like to be able to feed a range to the script instead.
For example, right now all I can do is myscript.py server1, myscript.py server2
I would like to be able to pass myscript.py server1-20 and it would execute the command on all 20 servers.
Any suggestions are appreciated.
Use ZSH.

Actually, bash supports this syntax also.
myscript.py server{1..20}
Expands to:
myscript.py server1 server2 server3 ... server20
Then simply process the argument list. If you have other arguments besides servers that get passed to your program, then make them options (as in, begin with one or two dashes... --long-option). You can also implement an option terminator option (just two dashes, --) to indicate that the rest of the arguments in the list are not options.