__author__ = 'jotasancent' import sys import io import subprocess def query_yes_no(question, default="yes"): """Ask a yes/no question via raw_input() and return their answer. "question" is a string that is presented to the user. "default" is the presumed answer if the user just hits . It must be "yes" (the default), "no" or None (meaning an answer is required of the user). The "answer" return value is True for "yes" or False for "no". """ valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} if default is None: prompt = " [y/n] " elif default == "yes": prompt = " [Y/n] " elif default == "no": prompt = " [y/N] " else: raise ValueError("invalid default answer: '%s'" % default) while True: sys.stdout.write(question + prompt) choice = raw_input().lower() if default is not None and choice == '': return valid[default] elif choice in valid: return valid[choice] else: sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n") nb = raw_input('Brightness level for the small monitor [0-1000]') f=open('/home/jotasancent/usr/brightness','w') f.write(nb) f.close() #print ("This is the file handler",f) while (query_yes_no("Do you want to adjust the brightness again?")): nb = raw_input('Brightness level for the small monitor [0-1000]') f=open('/home/jotasancent/usr/brightness','w') f.write(nb) f.close() print ("Now we are starting the network adapters, please wait") subprocess.call(["/home/jotasancent/usr/WifiNoNetManager_wpa.sh"], shell=True) with open('/var/tmp/list1', 'r') as f: myNames = [line.strip() for line in f] ----------- % environments=['stg','trn','prd'] % maybe a dictionary with tuples % environments = {'stg': 'IP1', 'trn': 'IP2', 'prd': 'IP3'} vserver_name='fixdb.mycompany4.com' % For each environment, create a vserver and use an available (non-used) IP. Preferably the same for all of them %add lb vserver vserver1 TCP 10.0.1.1 80 -persistenceType NONE -Listenpolicy None -cltTimeout 9000 for i in myNames: print(vserver_name+'.'+i) % Nitro API and configuration. See 1st logon in login1.py % REST and Python API to be downloaded here: % https://www.citrix.com/downloads/netscaler-adc/sdks/netscaler-sdk-release-105.html