I am writing a script to kick off a bat script in several client systems. I'd like to capture each system that fails. The issue i have is that it cycles through the clients and then my IF statement is run at the end. This sounds like the IF statement is in the wrong place but the logic seems fine to me.
clients = open("C:\client.csv", 'r') failedclients=[]
def kickoff(clients):
logging.info("Going through clients.csv")
for host in clients:
batkickoff = subprocess.call('C:\pstools\psexec.exe \\\\%s -d C:\test.bat' % hostname)
if batkickoff != 1:
print "there was an issue"
logging.info(hostname + " had an issue kicking off")
failedclients.append(hostname)
kickoff(clients)
So it will cycle through and kick off the bat script in each client. It DOESN'T execute my IF statement until the last loop.
Any help is appreciated.
Thanks in advance