|
楼主 |
发表于 2009-6-12 17:05:07
|
显示全部楼层
不过我最后用的这个
;~ 打开一个文件已共读写-----------------------------------------------------------------
$rzwj = FileOpen("测试日志.jun", 0)
; 检查打开的文件是否可读
If $rzwj = -1 Then
MsgBox(0, "错误", "不能打开文件.")
Exit
EndIf
Local $h = 1 ;确定行数
#include <array.au3>
#include <inet.au3>
While 1
$rzwjh = FileReadLine($rzwj)
If @error = -1 Then ExitLoop
;MsgBox(0, "读取的行:", $rzwjh)
$rzwjfg = StringSplit($rzwjh, ' ', 1)
;MsgBox(0, "读取的行的第二个字符串:", $rzwjfg[2])
Local $str_t2 = StringSplit($rzwjfg[2], ".")
If $str_t2[0] = 4 Then
;Local $tmp1 = StringReplace($str_t2[1], "*", ""), $tmp2 = StringReplace($str_t2[2], "*", ""), $tmp3 = StringReplace($str_t2[3], "*", ""), $tmp4 = StringReplace($str_t2[4], "*", "")
If StringLen($str_t2[1]) <= 3 And StringLen($str_t2[2]) <= 3 And StringLen($str_t2[3]) <= 3 And StringLen($str_t2[4]) <= 3 Then
;MsgBox(0,"",$rzwjfg[2])
IniWrite(@ScriptDir & "\日志过滤.ini", "过滤的结果", "第" & $h & "行", "过滤后为 " & $rzwjfg[2])
;~ 进行分析--------------------------------------------------------
Local $aResult, $sIp
TCPStartup()
$sIp = TCPNameToIP($rzwjfg[2])
$aResult = _TCPIpToName ($sIp, 1)
If @error Then
;MsgBox(0, "_TCPIpToName()", "@error = " & @error & @LF & "@extended = " & @extended)
IniWrite(@ScriptDir & "\分析日志.ini", "分析结果", "第" & $h & "行", "分析后为 ip:" & $rzwjfg[2]&"错误报告:"&@error)
Else
;~ _ArrayDisplay($aResult, "Local Hostname(s)")
;~ MsgBox(0,"1",$aResult[0])
;~ MsgBox(0,"2",$aResult[1])
;~ MsgBox(0,"3",$aResult[2])
;~ MsgBox(0,"4",$aResult[3])
IniWrite(@ScriptDir & "\分析日志.ini", "分析结果", "第" & $h & "行", "分析后为 " & $aResult[1])
EndIf
EndIf
EndIf
;~ 完成分析-----------------------------------------------------------------------
IniWrite(@ScriptDir & "\日志中的第二个字符串.ini", "第二个字符串", "第" & $h & "行,读取的信息 " & $rzwjfg[2], "读取的所有信息 " & $rzwjh)
$h = $h + 1
WEnd
FileClose($rzwj)
;~ ---------------------------------------------------------------------------------------- |
|