ipmitool 发表于 2016-8-3 11:33:03

如何抓取 txt 的 Memory 字元的前面三個 0x 裡面的英數字 並且output

本帖最后由 ipmitool 于 2016-8-3 11:45 编辑

請問如何抓取 txt 檔案裡面的 Memory 字元的前面三個 0x 裡面的英數字, 然後個別 output 到GUICtrlCreateInput 裡面?

ipmitool -H bncip -U Admin -P Admin -I lanplus sel save xx.txt
0x04 0x10 0x02 0x6f 0x02 0xff 0xff # Event Logging Disabled #0x02 Log area reset/cleared
0x04 0x0c 0xd2 0x6f 0xa0 0x00 0x00 # Memory #0xd2 Correctable ECC
0x04 0x0c 0xd2 0x6f 0xa0 0x00 0x51 # Memory #0xd2 Correctable ECC
0x04 0x0c 0xd2 0x6f 0xa0 0x00 0x01 # Memory #0xd2 Correctable ECC
0x04 0x0c 0xd2 0x6f 0xa0 0x00 0x18 # Memory #0xd2 Correctable ECC#include <Array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBoxEx.au3>


#include<array.au3>
#include <Excel.au3>

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>



$Form1 = GUICreate("Collect FIO Log Tool", 520, 540, -1, -1)

$Radio1        = GUICtrlCreateRadio("Collect1", 400, 50, 97, 25)
$Radio2        = GUICtrlCreateRadio("Collect2", 400, 80, 97, 25)
$Radio3        = GUICtrlCreateRadio("Collect3", 400, 110, 97, 25)

;$Button0 = GUICtrlCreateButton("Get BW/IOPS/CPU%", 5, 5, 140, 25, 0)
$Button1 = GUICtrlCreateButton("Analyze", 400, 150, 97, 50, 0)


$hLabel1 = GUICtrlCreateLabel("EventData", 30, 14, 97, 25, 0)
$hLabel2 = GUICtrlCreateLabel("EventData", 150, 14, 97, 25, 0)
$hLabel3 = GUICtrlCreateLabel("EventData", 270, 14, 97, 25, 0)

    GUISetState(@SW_SHOW)



;######################################################################
        Local $open, $exititem, $helpmenu, $aboutitem, $aboutitemRaw, $aboutitemFile;, $okbutton, $cancelbutton
        Local $msg;, $file
        $filemenu = GUICtrlCreateMenu("File")
        $open = GUICtrlCreateMenuItem("Open", $filemenu)
        $exititem = GUICtrlCreateMenuItem("Exit", $filemenu)

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


   ; HotKeySet("^c", "MyExit");設定中斷熱鍵

    Local $var = FileOpenDialog("Please select which Log you want to sorting...", @ScriptDir, " Please Select File (*.txt)")
    Local $file = FileOpen($var)

   $Input1 = GUICtrlCreateEdit("", 30, 30, 100, 175)
   $Input2 = GUICtrlCreateEdit("", 150, 30, 100, 175)
   $Input3 = GUICtrlCreateEdit("", 270, 30, 100, 175)

        ;HotKeySet("{enter}","_F1")
        GUICtrlCreateLabel("Data1", 35, 215, 50, 23)
        GUICtrlCreateLabel("Data2", 105, 215, 50, 23)
        GUICtrlCreateLabel("Data3", 180, 215, 50, 23)

        $out_collect1 = GUICtrlCreateInput("", 30, 230, 50, 23)
        $out_collect2 = GUICtrlCreateInput("", 100, 230, 50, 23)
        $out_collect3 = GUICtrlCreateInput("", 175, 230, 50, 23)

        $out_collect4 = GUICtrlCreateInput("", 30, 280, 50, 23)
        $out_collect5 = GUICtrlCreateInput("", 100, 280, 50, 23)
        $out_collect6 = GUICtrlCreateInput("", 175, 280, 50, 23)

        $out_collect7 = GUICtrlCreateInput("", 30, 330, 50, 23)
        $out_collect8 = GUICtrlCreateInput("", 100, 330, 50, 23)
        $out_collect9 = GUICtrlCreateInput("", 175, 330, 50, 23)

Func _F1()
                send("{Tab}")
EndFunc

;send("^z")



While 1
    ;read printer information
    $line = FileRead($file)
    $prn000 = StringRegExp($line, "0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) # Memory", 3)
        $prn001 = StringRegExp($line, "0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) # Memory", 3)
        $prn002 = StringRegExp($line, "0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) 0x(.*) # Memory", 3)


for $i = 0 to UBound($prn000) - 1
$CollectHDD1 = GUICtrlSetData ($Input1, $prn000[$i] &@CRLF,1)
$CollectHDD11 = ControlGetText("Collect1","",10)
Next

for $j = 0 to UBound($prn001) - 1
$CollectHDD2 = GUICtrlSetData ($Input2, $prn001[$j] &@CRLF,1)
$CollectHDD22 = ControlGetText("Collect2","",11)
Next

for $k = 0 to UBound($prn002) - 1
$CollectHDD3 = GUICtrlSetData ($Input3, $prn002[$k] &@CRLF,1)
$CollectHDD33 = ControlGetText("Collect3","",12)
Next



        $Msg = GUIGetMsg()
        Switch $Msg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button1

        if BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)=1 Then
                        MsgBox(0,"123","123",1)
        EndIf



        if BitAnd(GUICtrlRead($Radio2),$GUI_CHECKED)=1 Then
                        MsgBox(0,"123","123",1)
        EndIf



        if BitAnd(GUICtrlRead($Radio3),$GUI_CHECKED)=1 Then
                        MsgBox(0,"123","123",1)
        EndIf


EndSwitch

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

                Select
                        Case $msg = $exititem
                                ExitLoop

                        Case $msg = $open
                                Local $var = FileOpenDialog("Please select which Log you want to sorting...", "c:\", " Please Select File (*.txt)")
                                Local $file = FileOpen($var)

                                        ;Case $msg = $okbutton
                                        ;        MsgBox(0, "Click", "You clicked OK!")


                EndSelect


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



WEnd

ipmitool 发表于 2016-8-4 08:11:09

請問有大師有辦法處理這一條難解的問題嗎? 拜託了~

紫月Q 发表于 2016-8-4 11:34:14

http://www.autoitx.com/thread-38736-1-1.html 如果你的字符内容是固定的 那么难度不高如果只是大致格式固定 那么你还得等后来者帮忙。

ipmitool 发表于 2016-8-4 13:35:57

內容不是固定的...會變, 只是格式是一樣的. 只要取最後三個 0x 裡面的英數字元

afan 发表于 2016-8-4 14:12:48

(?mi)0x(\S+)\h+0x(\S+)\h+0x(\S+)\h+#\h+Memory\h+

zxhou1 发表于 2016-8-6 15:38:58

{:face (270):}
页: [1]
查看完整版本: 如何抓取 txt 的 Memory 字元的前面三個 0x 裡面的英數字 並且output