BlazeLondon Posted April 13, 2006 Share Posted April 13, 2006 Does anyone have a script that could easily be modified to read a mail server log fileand pick out the email address ABOVE the line that has @workplaceintelligence in itIn this example the bits the script should find are in boldT 20051213 123231 439857bb MAIL FROM:<qc.rentals@wanadoo.fr> SIZE=4005T 20051213 123231 439857bb RCPT TO:<info@workplaceintelligence.co.uk>T 20051213 123231 439857bb MAIL FROM:<bill@barclays.co.uk> SIZE=4005T 20051213 123231 439857bb RCPT TO:<jon@bluespring.co.uk>T 20051213 123231 439857bb MAIL FROM:<ram@btinternet.co.uk> SIZE=4005T 20051213 123231 439857bb RCPT TO:<info@workplaceintelligence.net> Link to comment Share on other sites More sharing options...
Valuater Posted April 13, 2006 Share Posted April 13, 2006 (edited) maybe#include <File.au3> $File_name = "logfile.txt" $find = "Computer 3" $num = _FileCountLines($File_name) For $x = $num to 1 Step -1 $line = FileReadLine($File_name, $x) If StringInStr($line, $find) Then MsgBox(64, "Found", $find & " on line # " & $x & " ") ; do what you want EndIf Nexti wrote this ealier todaythen use stringbetween.. its in herehttp://www.autoitscript.com/forum/index.ph...70&hl=Valuater#8) Edited April 13, 2006 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted April 13, 2006 Share Posted April 13, 2006 Lesson 15 from Welcome to Autoit 1-2-3 ( IE.au3 example ) expandcollapse popup; demonstration to find chracters that change between to standard points ; or just find a string #include <IE.au3> #Region --- IE-Builder generated code Start --- $oIE = _IECreate () ;------------- User input -------------- _IENavigate ($oIE, "http://www.autoitscript.com/"); web address $Find = "LZ"; my info shows after this line... or just find this line $Before = "comp"; my info shows before this line... or set as "" ; ------------ End User input ------------- Sleep(1000) $body = _IEBodyReadHTML ($oIE) $sloc = @TempDir & "\stest.txt" FileDelete($sloc) FileWrite($sloc, $body) $sfile = FileOpen($sloc, 0) $num = 0 While 2 $num = $num + 1 $sline = FileReadLine($sfile, $num) If @error Then MsgBox(262208, "Fail", "The string was NOT found ") FileClose($sfile) Exit EndIf If StringInStr($sline, $Find) Then MsgBox(64, "Success", "The string " & $Find & " was found " & @CRLF & " on line # " & $num, 5) If $Before = "" Then ExitLoop $Found = stringbetween($sline, $Find, $Before) MsgBox(64, "Found", "The string is " & $Found & " ", 5) ExitLoop EndIf WEnd Func stringbetween($str, $start, $end) $pos = StringInStr($str, $start) If Not @error Then $str = StringTrimLeft($str, $pos + StringLen($start) - 1) $pos = StringInStr($str, $end) If Not @error Then $str = StringTrimRight($str, StringLen($str) - $pos + 1) Return $str EndIf EndIf EndFunc ;==>stringbetween #EndRegion --- IE-Builder generated code End --- just change the top lines 8) 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