我如何知道已經用root帳戶登錄了多少次?Python閱讀文件
這裏是我使用至今在Python代碼:
myFile = open('file','r')
count_rr = 0
for line in myFile.readlines():
list_of_line = line.split(' ')
if 'root' in list_of_line[?]
print 'root'
count_rr = counter_rt + 1
下面是該文件的兩行我想讀:
Jan 10 09:32:46 j4-be03 sshd[3885]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=218.241.173.35 user=root
Jan 10 09:32:48 j4-be03 sshd[3885]: Failed password for root from 218.241.173.35 port 50212 ssh2
你想要所有的登錄嘗試或只是失敗的?請更新問題和標題(它太籠統了),使其更清晰。 – jcollado 2012-02-15 13:11:33