我的目的是想要截取log文档最后面的 $checkLine 行文本,然后收尾加点内容,变成html。
遇到的问题是,产生的 index.html 中,始终没有 $htmlFoot 中的哪些内容。
恳请各位不吝指教,谢谢!
;~ Defult value
$fileName = "D:\tenwa\log\jk_log.log"
$outFileName = "D:\Lotus\Domino\data\domino\html\tmphtml\index.html"
$checkLine = 500
$sleepTime = 5
$strURL = "http://172.16.80.25/tmphtml/index.html#end"
$htmlHead = "<html><HEAD>" & @CRLF
$htmlHead = $htmlHead & "<TITLE>interface log, " & $sleepTime & "' refresh </TITLE>" & @CRLF
$htmlHead = $htmlHead & '<META HTTP-EQUIV="REFRESH" CONTENT="' & $sleepTime & '; URL=' & $strURL & '">' & @CRLF
$htmlHead = $htmlHead & "</HEAD><body><pre>" & @CRLF
$htmlFoot = '<a href="" name="end">[end]</a>' & @CRLF
$htmlFoot = $htmlFoot & "</pre></body></html>" & @CRLF
$fileLineCount = _FileCountLines($fileName)
$skipLine =0
if $fileLineCount > $checkLine Then
$skipLine = $fileLineCount - $checkLine
endif
$fileBody = ""
$N = FileGetSize($fileName) - 1
$M= ""
If @error Or $N = -1 Then
;~ skip
Else
$file = FileOpen($fileName, 0)
$M=FileRead($file)
FileClose($file)
$M=StringReplace($M,@CRLF,@CR)
$M=StringSplit($M,@CR)
For $i = $M[0] - $checkLine to $M[0]
$fileBody = $fileBody & $M[$i] & @CRLF
Next
$outFile = FileOpen($outFileName, 2)
FileWrite($outFile, $htmlHead & $fileBody & $htmlFoot)
FileClose($outFile)
EndIf
|