text file

Tim Golden mail at timgolden.me.uk
Wed Oct 1 12:52:57 EDT 2008


yqyq22 at hotmail.com wrote:
> HI all,
> i have some problem with the code belove, i have a list of servers in
> a textfile (elencopc.txt).... i would to retrieve informations via WMI
> ( cicle for ), but i don't understand if the code is correct:


Try this, using http://timgolden.me.uk/python/wmi.html :

<code>
import wmi

#
# For the test to work
#
open ("elencopc.txt", "w").write ("localhost")

for server in open ("elencopc.txt").read ().splitlines ():
   c = wmi.WMI (server)
   print "SERVER:", server
   for item in c.Win32_QuickFixEngineering ():
     print item # or print item.Caption, etc.
   print
   print

</code>

If you get RPC Server unavailable, it usually means that
the WMI service isn't running on that machine. Usually.

TJG



More information about the Python-list mailing list