Am trying to create inventory report for set of windows servers using following function. But, this function always fails ping test for all hosts, though am apple to ping a few of them cleanly from command line. tried multiple combination, not able to figure out what is limiting it from hitting ping pass block ? please suggest,
def StartInvetoryCollection() :
for eachline in open('HostList.txt', 'r') :
RemoteHost = eachline.strip()
print(RemoteHost, end='')
if os.system('ping RemoteHost -c 4') == 0 :
print('\t\tPING=PASS',end='')
ReportFileName = RemoteHost + '_msinfo.txt'
os.system('msinfo32 /computer Host /report ReportFileName')
print('\tData Collection=PASS')
else :
print('\t\tPING=FAIL\tData Collection=SKIP')
pass
Hostlist.txt - contains one hostname per line
You have to pass your value into the
os.system
: