By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,172 Members | 762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,172 IT Pros & Developers. It's quick & easy.

New to Python

P: 1
Hello all;
I am 1 of 8 System Administrators managing 800+ Microsoft/Linux servers.
I have a ServerName_list.txt file. I want to parse this txt file line by line for each line get specific Microsoft OS info:

file = open('c:/tmp/test.txt', 'rwa')
# file = open('c:/tmp/output.txt', 'rwa')
while 1:
lines = file.readlines(100000)
if not lines:
for line in lines:
import win32com.client
strComputer = line
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocat or")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv 2")
colItems = objSWbemServices.ExecQuery("Select * from Win32_OperatingSystem")
for objItem in colItems:
print objItem.Caption, objItem.CSDVersion, objItem.CSName

Error message:
>>> Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\" , line 305, in RunScript, __main__.__dict__, start_stepping=1)
File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\", line 60, in run
_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\", line 631, in run
exec cmd in globals, locals
File "F:\Data\Scripts\Python Stuff\", line 11, in <module>
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv 2")
File "<COMObject WbemScripting.SWbemLocator>", line 5, in ConnectServer
File "C:\Python25\Lib\site-packages\win32com\client\", 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)

Any one have any suggestions?
Dec 5 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.