keilamym Posted February 28, 2005 Share Posted February 28, 2005 does anyone know of a way to have autoit query a file for specific contents. i'd like to run pslist to list and export the contents based on a variable. $workstation = InputBox ( "title name here", "box contents here.","") RunWait(@ComSpec & " /c " & 'c:\pstools\pslist.exe \\' & $workstation & " >" & $workstation & ".log", "c:\pstools") that portion works. i'd like to have autoit, read the contents of the file i just created to look for the word "update" based on the return code, i can process different procedures. i just dont know how to get it to query the file. thanks in advance for anyone help. Keilamym Link to comment Share on other sites More sharing options...
keilamym Posted March 1, 2005 Author Share Posted March 1, 2005 is it even possible to have auto find text within a log file? Link to comment Share on other sites More sharing options...
JoeyJoeJOe Posted March 1, 2005 Share Posted March 1, 2005 Read the file into a string then use StringInStr() function. Link to comment Share on other sites More sharing options...
keilamym Posted March 1, 2005 Author Share Posted March 1, 2005 thanks Joey but i couldn't get it working.. i just opened the file to a window, used the window text options to find the text, then close the file. i think its sloppy but atleast it works. :"> Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 1, 2005 Share Posted March 1, 2005 (edited) thanks Joey but i couldn't get it working.. i just opened the file to a window, used the window text options to find the text, then close the file. i think its sloppy but atleast it works. :"><{POST_SNAPBACK}>Sloppy is right! But again, it does work.Try looking at the help file for the UDF _filereadtoarray()That way you can run a loop on the resultant array and extract the specific information if found.#include <file.au3> Dim $aRecords, $x, $flag = 0, $file = "C:\file.txt" If Not _FileReadToArray($file,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] If $aRecords[$x] = "Some Text" then ; or comment above and use the following line to search for a specific string within the record ; If Not StringInStr($aRecords[$x],"Some Text") = "" then $flag = 1 ExitLoop EndIf Next If $flag = 1 then MsgBox(0,"Record: " & $x, $aRecords[$x]) Else MsgBox(0,"Error", "Unable to locate string") EndIfThat was just modified from the help file and should help you along. Make sure to #include <file.au3> at the start of your program otherwise you'll get an Unidentified Function name.Edit: Put the $flag variable in front of the ExitLoop. Silly mistake. Edited March 1, 2005 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now