Thursday 26 March 2009

Python scripts called from $

An example:


import sys
if __name__ == '__main__':
# Executed, only if called from command line.
args = sys.argv

if len(args) == 1:
print 'No argument specified. call as filename.py '
exit()
else:
print 'Argument(s) provided: ', args

No comments:

Post a Comment