Am using python script to execute a curl command on a list of servers and write the output to individual servers. below is the config file
server1, server2, server3
And the python script is written in to achieve that my script should read one server name at a time and write the output of that server into a individual file. like this if three server name, means three files with respective output in each file. But in actual when the script executes it writes the output to first file. When it read second server name it writes the output of first server and second server to second file and so on . which ideal should not could any one tell me what am doing wrong in the below script
import os
import pycurl
import StringIO
import fileinput
import sys
response=StringIO.StringIO()
opfilename="output.log"
configfile="config.properties"
file=open(configfile,'r')
counter=0
length=0
with open(configfile,'r') as configfile:
for items in configfile:
line=items.strip()
values=line.split(",")
length=len(values)
while counter < length:
print counter
servername=values[counter]
print servername
c=pycurl.Curl()
c.setopt (c.URL, 'http://'+servername+':port/solr/admin/cores?action=STATUS')
c.setopt (c.WRITEFUNCTION, response.write)
c.perform()
f=open(servername+'output.log','w')
print >> f, response.getvalue() + '\r' + '\n'
counter=counter+1
c.close()
response.close()