



Hello All;
I am a System Admin for a mixed Microsoft/Linux enviornment.
The script (Active py v2.5)below is attempting to parse an input file containing a list of server names. For each line in txt file it is suppose to pass the server name off to a "strComputer" variable (script works up to this point).
(This is were the script breaks) Then using strComputer querry correct registry and write CSName and CSDVersion to a logfile.
while 1:
lines = infile.readlines(100000)
if not lines:
break
for line in lines:
import win32com.client
strComputer = line
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
colItems = objSWbemServices.ExecQuery("Select * from Win32_OperatingSystem")
for objItem in colItems:
CSName = objItem.CSName
CSDVersion = objItem.CSDVersion
logfile.write(CSDVersion)
logfile.write(' ')
logfile.write(CSName)
logfile.write('\n')
logfile.close
print file('c:/tmp/output.txt').read()
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "F:\Data\Scripts\Python Stuff\Write OS & SP.py", line 11, in
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
File "", line 5, in ConnectServer
File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 258, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
com_error: (-2147352567, 'Exception occurred.', (0, 'SWbemLocator', 'The RPC server is unavailable. ', None, 0, -2147023174), None)
Can someone explain to me what I'm doing wrong and show me how to correct my script.
Thanks