找回密码
 加入
搜索
查看: 2426|回复: 13

[AU3基础] [已解决]有人有辦法擷取putty的文字 並且抓出想要的字串嗎?

  [复制链接]
发表于 2017-1-6 17:31:32 | 显示全部楼层 |阅读模式
本帖最后由 ipmitool 于 2017-1-9 13:41 编辑

有人有辦法擷取putty的文字 並且抓出想要的字串嗎?
putty的視窗會一直跑字出來, 所以要偵測這個視窗, 然後抓出  192.8.1.175:1 變成一個變數

本帖子中包含更多资源

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

×
发表于 2017-1-6 19:39:01 | 显示全部楼层
开启putty的日志功能,然后用正则提取IP
发表于 2017-1-6 20:59:17 | 显示全部楼层
楼上思路不错~
 楼主| 发表于 2017-1-8 21:12:13 | 显示全部楼层
回复 2# q410225


    不過要如何指定那個位置而找到ip呢?
发表于 2017-1-8 22:47:50 | 显示全部楼层
回复 4# ipmitool


    Afan有个匹配ip的正则,要不你就百度一下匹配IP的正则
 楼主| 发表于 2017-1-9 08:55:59 | 显示全部楼层
回复 5# austere

他那篇回覆的看不太明白...
如果要正則抓取這個檔案裏面的 192.8.1.175:1 要如何做啊...

本帖子中包含更多资源

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

×
发表于 2017-1-9 09:39:47 | 显示全部楼层
(\d{1,3}\.){3}\d{1,3}(:\d+)?
不是很严谨
 楼主| 发表于 2017-1-9 09:57:20 | 显示全部楼层
回复 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
发表于 2017-1-9 10:00:24 | 显示全部楼层
$prn000 = StringRegExp($line, "(\d{1,3}\.){3}\d{1,3}(:\d+)?", 4)
先看下结果,然后取对应的
发表于 2017-1-9 10:02:33 | 显示全部楼层
正则返回的是数组
发表于 2017-1-9 10:14:46 | 显示全部楼层
#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])[0] & @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
 楼主| 发表于 2017-1-9 10:36:57 | 显示全部楼层
回复 11# zghwelcome


謝謝您, 不過去讀zip裡面的 txt 檔案時, 抓不到 192.8.1.175:1

本帖子中包含更多资源

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

×
发表于 2017-1-9 11:29:32 | 显示全部楼层
#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])[0] & @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

评分

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

查看全部评分

 楼主| 发表于 2017-1-9 13:41:32 | 显示全部楼层
回复 13# zghwelcome


    好強啊~~謝謝大哥~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-27 09:29 , Processed in 0.082712 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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