특정구문 넣기 소스
#!/usr/bin/python

import sys , os
from cStringIO import StringIO


if len(sys.argv) < 2:
        print "error! example) repl.py directory"
        raise SystemExit

fileslist = os.popen("find %s -iname '*.asp'" % sys.argv[1]).readlines()

for fn in fileslist:
        # make backups
        fn = fn.strip()
        os.system( "cp -f %s %s" % ( fn , fn + ".bak") )
        nf = StringIO()
        lineno = 0
        for c in open(fn):
                if "<body" in c:
                        nf.write(c)
                        nf.write("<div id='zoomCtrl' style='position:absolute;top:0px;left:0p;'><!-- Space Zoom start-->")
                        os.system( "echo FILE:%s LINENO:%s >> header.log" % ( fn , lineno ) )
                elif "</body>" in c:
                        nf.write("</div> <!-- Space Zoom End -->")
                        nf.write(c)
                        os.system( "echo FILE:%s LINENO:%s >> footer.log" % ( fn , lineno ) )
                else:  
                        nf.write(c)
                lineno += 1
        nf.seek(0)
        open(fn,'w').write(nf.read())
특정구문 빼기 소스

#!/usr/bin/python

import sys , os
from cStringIO import StringIO


if len(sys.argv) < 2:
        print "error! example) repl.py directory"
        raise SystemExit

fileslist = os.popen("find %s -iname '*.jsp'" % sys.argv[1]).readlines()

for fn in fileslist:
        # make backups
        fn = fn.strip()
        os.system( "cp -f %s %s" % ( fn , fn + ".bak") )
        nf = StringIO()
        lineno = 0
        for c in open(fn):
                if "<div id='zoomCtrl' style='position:absolute;top:0px;left:0p;'><!-- Space Zoom start-->" in c:
                        os.system( "echo FILE:%s LINENO:%s >> header.log" % ( fn , lineno ) )
                elif "</div> <!-- Space Zoom End -->" in c:
                        os.system( "echo FILE:%s LINENO:%s >> footer.log" % ( fn , lineno ) )
                else:  
                        nf.write(c)
                lineno += 1
        nf.seek(0)
        open(fn,'w').write(nf.read())


출처: http://rayx.in/2460827





신고
크리에이티브 커먼즈 라이선스
Creative Commons License

WRITTEN BY
김병국
유용했던 자료를 기록해 두었습니다. 도움이 되시길~~~ Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you fun

받은 트랙백이 없고 , 댓글이 없습니다.
secret