<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://community.activestate.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>ActiveState Community Site - Exception occurred.&amp;#039;, (0, &amp;#039;SWbemLocator&amp;#039;, &amp;#039;The RPC server is unavailable - Comments</title>
 <link>http://community.activestate.com/forum-topic/exception-occurred-0-swbemlocator-rpc-server-unavailable-1</link>
 <description>Comments for &quot;Exception occurred.&#039;, (0, &#039;SWbemLocator&#039;, &#039;The RPC server is unavailable&quot;</description>
 <language>en</language>
<item>
 <title>Exception occurred.&#039;, (0, &#039;SWbemLocator&#039;, &#039;The RPC server is unavailable</title>
 <link>http://community.activestate.com/forum-topic/exception-occurred-0-swbemlocator-rpc-server-unavailable-1</link>
 <description>&lt;p&gt;Hello All;&lt;br /&gt;
I am a System Admin for a mixed Microsoft/Linux enviornment.&lt;br /&gt;
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 &quot;strComputer&quot; variable (script works up to this point).&lt;br /&gt;
(This is were the script breaks) Then using strComputer querry correct registry and write CSName and CSDVersion to a logfile.&lt;/p&gt;
&lt;p&gt;while 1:&lt;br /&gt;
lines = infile.readlines(100000)&lt;br /&gt;
if not lines:&lt;br /&gt;
break&lt;br /&gt;
for line in lines:&lt;br /&gt;
import win32com.client&lt;br /&gt;
strComputer = line&lt;br /&gt;
objWMIService = win32com.client.Dispatch(&quot;WbemScripting.SWbemLocator&quot;)&lt;br /&gt;
objSWbemServices = objWMIService.ConnectServer(strComputer,&quot;root\cimv2&quot;)&lt;br /&gt;
colItems = objSWbemServices.ExecQuery(&quot;Select * from Win32_OperatingSystem&quot;)&lt;br /&gt;
for objItem in colItems:&lt;br /&gt;
CSName = objItem.CSName&lt;br /&gt;
CSDVersion = objItem.CSDVersion&lt;br /&gt;
logfile.write(CSDVersion)&lt;br /&gt;
logfile.write(&#039; &#039;)&lt;br /&gt;
logfile.write(CSName)&lt;br /&gt;
logfile.write(&#039;\n&#039;)&lt;br /&gt;
logfile.close&lt;br /&gt;
print file(&#039;c:/tmp/output.txt&#039;).read()&lt;/p&gt;
&lt;p&gt;Traceback (most recent call last):&lt;br /&gt;
File &quot;C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py&quot;, line 310, in RunScript&lt;br /&gt;
exec codeObject in __main__.__dict__&lt;br /&gt;
File &quot;F:\Data\Scripts\Python Stuff\Write OS &amp;amp; SP.py&quot;, line 11, in&lt;br /&gt;
objSWbemServices = objWMIService.ConnectServer(strComputer,&quot;root\cimv2&quot;)&lt;br /&gt;
File &quot;&quot;, line 5, in ConnectServer&lt;br /&gt;
File &quot;C:\Python25\Lib\site-packages\win32com\client\dynamic.py&quot;, line 258, in _ApplyTypes_&lt;br /&gt;
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)&lt;br /&gt;
com_error: (-2147352567, &#039;Exception occurred.&#039;, (0, &#039;SWbemLocator&#039;, &#039;The RPC server is unavailable. &#039;, None, 0, -2147023174), None)&lt;/p&gt;
&lt;p&gt;Can someone explain to me what I&#039;m doing wrong and show me how to correct my script.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
</description>
 <comments>http://community.activestate.com/forum-topic/exception-occurred-0-swbemlocator-rpc-server-unavailable-1#comments</comments>
 <category domain="http://community.activestate.com/forums/activepython-discussion-0">ActivePython discussion</category>
 <category domain="http://community.activestate.com/os/windows-server-2003">Windows Server 2003</category>
 <pubDate>Thu, 06 Dec 2007 13:51:43 -0600</pubDate>
 <dc:creator>jdmccla</dc:creator>
 <guid isPermaLink="false">1712 at http://community.activestate.com</guid>
</item>
</channel>
</rss>
