import re
def device_template(target_file,m,n):
f_read=open("./tor_temp","r").read()
file_read=re.split(r"([ \n._])",f_read)
for line in file_read:
f_write=open(target_file,"a+")
if line in n:
j=n.index(line)
new_line=line.replace(line,m[j])
f_write.write(new_line)
else:
f_write.write(line)
def main():
f=open("./canshu","r")
file_read=f.readlines()
variable=[]
variable=file_read[0].strip('\n').split(',')
print(variable)
count=0
for i in range(1,len(file_read)):
c=[]
c=file_read[i].strip('\n').split(',')
target_file="/home/zhangli/dns_replace/www/peizhi/"+c[0]+".txt"
print(c[i])
device_template(target_file,c,variable)
count=count+1
print(count)
main()