python - How to make a command line argument of a while loop number? -


import os  commands = ['uname -v', 'whoami']  = 0   numberiterations = 2    # how make command line argument of while loop number?   while < numberiterations:       print "#--- iteration: %s ---#" %       = 0       while < len(commands):           print "$", commands[i]           os.system(commands[i])           = + 1       print ""       = + 1   

i want run script in format:
./script.py "numberiterations"

grab str sys.argv , convert int.

import sys try:   numberiterations = int(sys.argv[1]) except indexerror:   print "usage: %s numberiterattions" % sys.argv[0]   raise systemexit(1) 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -