I am pretty new to coding, and I am attempting to have a user input words (zones). I want these to be put into a list that can be used to pull from based on the counter. The rest of the input is being pulled from a file and then then broken up using shlex.split. I'm then naming these linetokens and using them for my if statements and my naming. I was wondering if someone could look at the following code and let me know what I'm doing wrong. I don't receive any errors when I run it; however, nothing happens. I'm using python 2.7. *After adding the "main(sys.argv[1])", the script now runs but I am still receiving errors.
import sys
import shlex
def inputZone(zone):
zones = raw_input('Enter zones: ')
return zone
def main(argv):
count = int(0)
zones = zone.split(' ')
sys.stdout.flush
argv = sys.argv
if len(sys.argv) != 2:
configfile = open(str(sys.argv(1),'r'))
for configline in configfile:
with open('converted.txt','a') as converted:
linetokens = shlex.split(configline)
while count <= len(zones):
if(linetokens[0]=='set' and linetokens[1]=='group' and linetokens[3]==zones[count] and linetokens[5]=='add'):
groupObject=linetokens[4].replace(' ','_').replace('[','').replace(']','').strip()
groupZone=linetokens[3].strip(' ')
addressObjectName=linetokens[6].replace(' ','').replace('[','').replace(']','')
converted.write("set security zones security-zone " + groupZone + " address-book address-set " + groupObject + " address " + + addressObjectName +'\n')
count = count + 1
configfile.close()
main(sys.argv[1])