hello sir,

my work is run version.sh file and collect the values of version and type in the output. i have around 500 servers,so i want to automate this process using pyhton. i had written sample code shown below, but it is not giving good results.will you please help me with correct code,

import commands
import re

com = "sh version.sh"
print outpu
result = re.findall(r"versio * | type*",output)
print result
print zip (*[ iter (result) ] *2)
print [tuple (x.strip() for x in y.split (" ")) for y in result]


com: command not found

and my version.sh file is like this

Product List
Name                     HTTPD

Installed Product
Type                       PLG
Build Level              b06.14
Build Date               5/16/06

End Status Report

If I understand correctly you're having a problem parsing the return of "version.sh" which looks like the 15-line report. Try this:
Insert after "output=commands.....":

for i in outlist:
   if i.startswith("Version"): vers=i.split()[1]
   if i.startswith("Type"): type=i.split()[1]

Then make your "result=..." however you want to format vers and type.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.