I need help to finalize my Python script for generating a control report from various hosts on Citrix netscaler sdx.
How do I finalize the out_file line below ???
if __name__ == "__main__":
load_dotenv()
with open('sdx_list.csv') as sdx_csv_file:
sdx_list = [(hostname, socket.gethostbyname(hostname)) for hostname in [x.strip() for x in (sdx_csv_file)]]
out_file = open('output.csv', 'w')
out_file.write('name;ip;comm_method;nsroot;ntp;tls;syslog;system_timeout\n')
out_file.close()
for sdx in sdx_list:
try:
token = nitro_login(sdx[1], os.getenv('sdx_username'), os.getenv('sdx_password'))
except: pass
if token:
comm_method = get_ns_comm(sdx[0], token)
nsroot = nitro_login_nsroot(sdx[0])
ntp = get_ntp(sdx[0], token)
tls = get_tls(sdx[0], token)
syslog = get_syslog(sdx[0], token)
system_timeout = get_system_timeout(sdx[0], token)
with open('output.csv', 'a') as results:
results.write(f"{sdx[0]};{sdx[1]};{','.join(comm_method)};{','.join(nsroot)};{','.join(ntp)};{','.join(tls)};{','.join(syslog)};{','.join(system_timeout)}\n")
Is it "out_file(results)" or ???