[已解决]有人有辦法擷取putty的文字 並且抓出想要的字串嗎?
本帖最后由 ipmitool 于 2017-1-9 13:41 编辑有人有辦法擷取putty的文字 並且抓出想要的字串嗎?
putty的視窗會一直跑字出來, 所以要偵測這個視窗, 然後抓出192.8.1.175:1 變成一個變數
开启putty的日志功能,然后用正则提取IP 楼上思路不错~ 回复 2# q410225
不過要如何指定那個位置而找到ip呢? 回复 4# ipmitool
Afan有个匹配ip的正则,要不你就百度一下匹配IP的正则 回复 5# austere
他那篇回覆的看不太明白...
如果要正則抓取這個檔案裏面的 192.8.1.175:1 要如何做啊... (\d{1,3}\.){3}\d{1,3}(:\d+)?不是很严谨 回复 7# zghwelcome
好像沒辦法耶...一直跑出1#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, 230, -1, -1)
$Radio1 = GUICtrlCreateRadio("Collect 1HDD", 400, 50, 97, 25)
$Button1 = GUICtrlCreateButton("Collect Log", 400, 150, 97, 25, 0)
$hLabel1 = GUICtrlCreateLabel("BW", 30, 14, 97, 25, 0)
GUISetState(@SW_SHOW)
Local $var = FileOpenDialog("請選擇要開啟的檔案", "c:\data", " TXT(*.*) ")
Local $file = FileOpen($var)
$Input1 = GUICtrlCreateEdit("", 30, 30, 100, 175)
While 1
;read printer information
$line = FileRead($file)
$prn000 = StringRegExp($line, "(\d{1,3}\.){3}\d{1,3}(:\d+)?", 3)
GUICtrlSetData ($Input1, $prn000 &@CRLF,1)
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
if BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)=1 Then
RunWait(@DesktopDir&"\dopdf-7.exe","")
EndIf
EndSwitch
WEnd
$prn000 = StringRegExp($line, "(\d{1,3}\.){3}\d{1,3}(:\d+)?", 4)
先看下结果,然后取对应的 正则返回的是数组 #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, 230, -1, -1)
$Radio1 = GUICtrlCreateRadio("Collect 1HDD", 400, 50, 97, 25)
$Button1 = GUICtrlCreateButton("Collect Log", 400, 150, 97, 25, 0)
$hLabel1 = GUICtrlCreateLabel("BW", 30, 14, 97, 25, 0)
GUISetState(@SW_SHOW)
Local $var = FileOpenDialog("請選擇要開啟的檔案", "c:\data", " TXT(*.*) ")
$Input1 = GUICtrlCreateEdit("", 30, 30, 100, 175)
While 1
;read printer information
$line = FileRead($var)
$prn000 = StringRegExp($line, "(\d{1,3}\.){3}\d{1,3}(:\d+)?", 4)
If Not @error Then
For $i = 0 To UBound($prn000) - 1
GUICtrlSetData($Input1, ($prn000[$i]) & @CRLF, 1)
Next
Sleep(5000)
EndIf
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = 1 Then
RunWait(@DesktopDir & "\dopdf-7.exe", "")
EndIf
EndSwitch
WEnd
回复 11# zghwelcome
謝謝您, 不過去讀zip裡面的 txt 檔案時, 抓不到 192.8.1.175:1
#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, 230, -1, -1)
$Radio1 = GUICtrlCreateRadio("Collect 1HDD", 400, 50, 97, 25)
$Button1 = GUICtrlCreateButton("Collect Log", 400, 150, 97, 25, 0)
$hLabel1 = GUICtrlCreateLabel("BW", 30, 14, 97, 25, 0)
GUISetState(@SW_SHOW)
Local $file = FileOpenDialog("請選擇要開啟的檔案", "c:\data", " TXT(*.*) ")
$Input1 = GUICtrlCreateEdit("", 30, 30, 100, 175)
While 1
;read printer information
$sRead = BinaryToString(FileRead($file),4)
$prn000 = StringRegExp($sRead, "(\d{1,3}\.){3}\d{1,3}(:\d+)?", 4)
If Not @error Then
For $i = 0 To UBound($prn000) - 1
GUICtrlSetData($Input1, ($prn000[$i]) & @CRLF, 1)
Next
Sleep(5000)
EndIf
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = 1 Then
RunWait(@DesktopDir & "\dopdf-7.exe", "")
EndIf
EndSwitch
WEnd
回复 13# zghwelcome
好強啊~~謝謝大哥~~
页:
[1]