找回密码
 加入
搜索
查看: 2851|回复: 9

[AU3基础] [已解决]如何查找Txt關鍵字並且列出關鍵字那一行?

  [复制链接]
发表于 2017-3-7 18:08:31 | 显示全部楼层 |阅读模式
本帖最后由 ipmitool 于 2017-3-8 18:51 编辑

如何查找 Txt 關鍵字並且列出關鍵字那一行?
Found (.*) suspect error
列出(.*) 及 當行的字串
#include <FileConstants.au3>
#include <File.au3>


FileDelete("AnalyzeWCSLog.txt")



$CycleTime=InputBox ("Input Cycle Time" , "Please input Cycle Time "   & @CRLF _
                                                 & @CRLF _
                         &"" ,"","")
                if $CycleTime="" then Exit




for $i=1 to $CycleTime

;######################################################################################################################

    ;get all folder names
    $FileList = _FileListToArray(@ScriptDir&"\cycle"&$i, "Check-WcsError*", 2)
    $fFolder = _ArrayToString($FileList)
    $fFolder = StringTrimLeft($fFolder, 2)
        ;MsgBox(0,"111",$fFolder)



        $Openlog = FileOpen(@ScriptDir&"\cycle"&$i&"\Check-WcsError-Summary.log")

        $filelog = @ScriptDir&"\cycle"&$i&"\Post-Test"&$fFolder&"\Check-WcsError-Summary.log"
        $OpenlogReadLine = FileReadLine($Openlog,6)

        ;MsgBox(0,"111",$OpenlogReadLine)

;######################################################################################################################


$filelog = @ScriptDir&"\cycle"&$i&"\Check-WcsError-Summary.log"
Local $scriptfilelog = FileOpen($filelog)
$line = FileRead($scriptfilelog)
$False = StringRegExp($line, "Found (.*) suspect error", 3)



for $k = 0 to UBound($False) - 1
        $FalseK001=$False[$k]


        If $FalseK001="NO" then

        Else

                $filelogsss = FileOpen("AnalyzeWCSLog.txt", 1)
                FileWriteLine($filelogsss, "Cycle Time: "&$i&", Error: "&$FalseK001)
                FileWriteLine($filelogsss, "")
                FileClose($filelogsss)

        EndIf


Next

Next


if FileExists(@ScriptDir&"\AnalyzeWCSLog.txt") Then
        MsgBox(0,"Message","Please check AnalyzeWCSLog.txt")
Else
        MsgBox(0,"Message","PASS! No Error Logs found!")
EndIf

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2017-3-8 10:04:31 | 显示全部楼层
回复 1# ipmitool
好象加个判断就可以

$FalseK001 = $False[$k]
If $CycleTime=$FalseK001 Then
 楼主| 发表于 2017-3-8 11:26:21 | 显示全部楼层
回复 2# chzj589


    可是...$CycleTime是資料夾的數字耶...
发表于 2017-3-8 11:30:23 | 显示全部楼层
这种借助命令行的 findstr 处理相当便捷
findstr /c:"test" c:\1.txt
得到文件中 c:\1.txt 所有含字符串 test 的行
发表于 2017-3-8 11:31:53 | 显示全部楼层
回复 3# ipmitool
你可以调试一下
$CycleTime是資料夾的數字
$FalseK001是读取的數字
发表于 2017-3-8 11:40:57 | 显示全部楼层
这种借助命令行的 findstr 处理相当便捷
findstr /c:"test" c:\1.txt
得到文件中 c:\1.txt 所有含字符串  ...
zghwelcome 发表于 2017-3-8 11:30


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2017-3-8 18:50:54 | 显示全部楼层
謝謝兩位大哥大大~
发表于 2017-3-9 19:12:35 | 显示全部楼层
謝謝兩位大哥大大~
ipmitool 发表于 2017-3-8 18:50








本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2017-3-10 08:20:30 | 显示全部楼层
回复 8# chzj589


    帥氣喔, 可不可以開放原碼, 之後用的上您的運用~
发表于 2017-3-10 08:38:23 | 显示全部楼层
回复 9# ipmitool

己发站内短信,请查收!

评分

参与人数 1金钱 +40 收起 理由
ipmitool + 40 謝謝老哥~~

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-19 12:44 , Processed in 0.080644 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表