[CentralOH] parsing Windows command line output

Eric Lake ericlake at gmail.com
Wed Jul 23 14:44:27 CEST 2008

I may have answered my own question. I know that this could probably
be done in a more elegant way so I am looking for suggestions. Here is
the code that I have come up with so far:

data = open('file.txt', 'r')


for line in data:
    clusdata = []
    info = line.split('  ')
    for x in info:
        if x != '':
            x = x.strip()
            if x .endswith('\\r\\n'):
                x = x.strip('\\r\\n')
    print clusdata


On Wed, Jul 23, 2008 at 7:52 AM, Eric Lake <ericlake at gmail.com> wrote:
> I have been looking for a way to monitor a Windows cluster that we
> have at work. I was really hoping for a good wmi class that I could
> use from my XP machine to do it but I have not been lucky finding one.
> I did however come across the 'cluster' command. I am thinking that I
> could just call that from within my python code and parse the output
> to get what I need. I want to get all of the data from the output and
> then put it in a database. I can not see how to split the lines up
> though. It would be easy if it was comma delimited but it seems to use
> a varying number of spaces. My only thought is that I could do a split
> on anything that is more than 2 spaces.
> The output of the command is in the attached file.
> --
> Thanks,
> Eric Lake


Eric Lake

More information about the CentralOH mailing list