2013/09/11

checking all offset with file

#!/usr/bin/python
import subprocess
import os

lv_file = open('log2.txt','rb')
lv_buf = lv_file.read()
lv_file.close()
ix=0
while ix <len(lv_buf):
    lv_out_file = open(str(ix)+'.tmp','wb')
    lv_out_file.write(lv_buf[ix:])
    lv_out_file.close()
    #file result
    lv_output = subprocess.Popen(['file',str(ix)+'.tmp'], stdout=subprocess.PIPE).communicate()[0]
    if lv_output.find(str(ix)+'.tmp: data')<0:
        open('output.txt','ab').write(str(ix)+' : '+lv_output.replace('.tmp: ','')+'\n')
    #end if
    os.system('rm '+str(ix)+'.tmp')
    ix=ix+1
#end while

0개의 덧글:

댓글 쓰기

에 가입 댓글 [Atom]

<< 홈