64,643
社区成员
发帖
与我相关
我的任务
分享
from ftplib import FTP
import re
import os
host = '10.101.50.25'
username = 'admin'
password = 'admin'
remotepatch = '/data1/admin/CSS/bin/tlog'
remotefile = 'tmp.log'
f = FTP(host)
print "Welcome:", f.getwelcome()
f.login(username,password)#=========》登陆
f.cwd(remotepatch)
#entries = f.nlst()
#entries.sort()
f.retrbinary('RETR '+remotefile, open(remotefile,'wb').write)
ff = open(remotefile,'r')
sizes = os.path.getsize(remotefile)
print sizes
p = re.compile('OrdSvcAcsRp,49:0')
if p:
lines = 1
count = 0
for line in ff.readlines():
p0 = p.findall(line)
if len(p0) !=0:
print p0,
print "matched at %s lines" %lines
count+=1
else:
pass
lines+=1
if count ==0:
print 'No matched!'
else:
print "None"
ff.close()
f.quit()