找回密码
 加入
搜索
查看: 3696|回复: 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 | 显示全部楼层
  1. (\d{1,3}\.){3}\d{1,3}(:\d+)?
复制代码
不是很严谨
 楼主| 发表于 2017-1-9 09:57:20 | 显示全部楼层
回复 7# zghwelcome


    好像沒辦法耶...一直跑出1
  1. #include <Array.au3>
  2. #include <ButtonConstants.au3>
  3. #include <ComboConstants.au3>
  4. #include <EditConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <WindowsConstants.au3>
  7. #include <GuiComboBoxEx.au3>
  8. #include<array.au3>
  9. #include <Excel.au3>
  10. #include <GUIConstantsEx.au3>
  11. #include <WindowsConstants.au3>
  12. #include <Constants.au3>



  13.     $Form1 = GUICreate("Collect FIO Log Tool", 520, 230, -1, -1)
  14.         $Radio1        = GUICtrlCreateRadio("Collect 1HDD", 400, 50, 97, 25)
  15.         $Button1 = GUICtrlCreateButton("Collect Log", 400, 150, 97, 25, 0)
  16.         $hLabel1 = GUICtrlCreateLabel("BW", 30, 14, 97, 25, 0)


  17.     GUISetState(@SW_SHOW)



  18.     Local $var = FileOpenDialog("請選擇要開啟的檔案", "c:\data", " TXT(*.*) ")
  19.     Local $file = FileOpen($var)

  20.     $Input1 = GUICtrlCreateEdit("", 30, 30, 100, 175)


  21. While 1
  22.     ;read printer information
  23.     $line = FileRead($file)
  24.     $prn000 = StringRegExp($line, "(\d{1,3}\.){3}\d{1,3}(:\d+)?", 3)


  25. GUICtrlSetData ($Input1, $prn000 &@CRLF,1)



  26.         $Msg = GUIGetMsg()
  27.         Switch $Msg
  28.                 Case $GUI_EVENT_CLOSE
  29.                         Exit
  30.                 Case $Button1
  31.                 if BitAnd(GUICtrlRead($Radio1),$GUI_CHECKED)=1 Then
  32.                         RunWait(@DesktopDir&"\dopdf-7.exe","")
  33.                 EndIf
  34. EndSwitch



  35. 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 | 显示全部楼层
  1. #include <Array.au3>
  2. #include <ButtonConstants.au3>
  3. #include <ComboConstants.au3>
  4. #include <EditConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <WindowsConstants.au3>
  7. #include <GuiComboBoxEx.au3>
  8. #include <array.au3>
  9. #include <Excel.au3>
  10. #include <GUIConstantsEx.au3>
  11. #include <WindowsConstants.au3>
  12. #include <Constants.au3>



  13. $Form1 = GUICreate("Collect FIO Log Tool", 520, 230, -1, -1)
  14. $Radio1 = GUICtrlCreateRadio("Collect 1HDD", 400, 50, 97, 25)
  15. $Button1 = GUICtrlCreateButton("Collect Log", 400, 150, 97, 25, 0)
  16. $hLabel1 = GUICtrlCreateLabel("BW", 30, 14, 97, 25, 0)

  17. GUISetState(@SW_SHOW)

  18. Local $var = FileOpenDialog("請選擇要開啟的檔案", "c:\data", " TXT(*.*) ")

  19. $Input1 = GUICtrlCreateEdit("", 30, 30, 100, 175)

  20. While 1
  21.         ;read printer information
  22.         $line = FileRead($var)
  23.         $prn000 = StringRegExp($line, "(\d{1,3}\.){3}\d{1,3}(:\d+)?", 4)
  24.         If Not @error Then
  25.                 For $i = 0 To UBound($prn000) - 1
  26.                         GUICtrlSetData($Input1, ($prn000[$i])[0] & @CRLF, 1)
  27.                 Next
  28.                 Sleep(5000)
  29.         EndIf


  30.         $Msg = GUIGetMsg()
  31.         Switch $Msg
  32.                 Case $GUI_EVENT_CLOSE
  33.                         Exit
  34.                 Case $Button1
  35.                         If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = 1 Then
  36.                                 RunWait(@DesktopDir & "\dopdf-7.exe", "")
  37.                         EndIf
  38.         EndSwitch

  39. WEnd
复制代码
 楼主| 发表于 2017-1-9 10:36:57 | 显示全部楼层
回复 11# zghwelcome


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

本帖子中包含更多资源

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

×
发表于 2017-1-9 11:29:32 | 显示全部楼层
  1. #include <Array.au3>
  2. #include <ButtonConstants.au3>
  3. #include <ComboConstants.au3>
  4. #include <EditConstants.au3>
  5. #include <GUIConstantsEx.au3>
  6. #include <WindowsConstants.au3>
  7. #include <GuiComboBoxEx.au3>
  8. #include <array.au3>
  9. #include <Excel.au3>
  10. #include <GUIConstantsEx.au3>
  11. #include <WindowsConstants.au3>
  12. #include <Constants.au3>



  13. $Form1 = GUICreate("Collect FIO Log Tool", 520, 230, -1, -1)
  14. $Radio1 = GUICtrlCreateRadio("Collect 1HDD", 400, 50, 97, 25)
  15. $Button1 = GUICtrlCreateButton("Collect Log", 400, 150, 97, 25, 0)
  16. $hLabel1 = GUICtrlCreateLabel("BW", 30, 14, 97, 25, 0)

  17. GUISetState(@SW_SHOW)

  18. Local $file = FileOpenDialog("請選擇要開啟的檔案", "c:\data", " TXT(*.*) ")

  19. $Input1 = GUICtrlCreateEdit("", 30, 30, 100, 175)

  20. While 1
  21.         ;read printer information
  22.         $sRead = BinaryToString(FileRead($file),4)
  23.         $prn000 = StringRegExp($sRead, "(\d{1,3}\.){3}\d{1,3}(:\d+)?", 4)
  24.         If Not @error Then
  25.                 For $i = 0 To UBound($prn000) - 1
  26.                         GUICtrlSetData($Input1, ($prn000[$i])[0] & @CRLF, 1)
  27.                 Next
  28.                 Sleep(5000)
  29.         EndIf


  30.         $Msg = GUIGetMsg()
  31.         Switch $Msg
  32.                 Case $GUI_EVENT_CLOSE
  33.                         Exit
  34.                 Case $Button1
  35.                         If BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = 1 Then
  36.                                 RunWait(@DesktopDir & "\dopdf-7.exe", "")
  37.                         EndIf
  38.         EndSwitch

  39. WEnd
复制代码

评分

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

查看全部评分

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


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

本版积分规则

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

GMT+8, 2026-9-22 16:07 , Processed in 0.068785 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2026 Discuz! Team.

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