hacksawbob Posted February 17, 2005 Share Posted February 17, 2005 Told you I'd be back I'm nearly there I just cant get my head 'round these new loops, so I am looking for a string in a text log file like "error" and net send a message if found I'm trying to do it with the filereadline to read each line in turn and search for the string error in each line. Pretty ungraceful I know but I guess I'm still in autoit V2 mode. #include <file.au3> $CountLines = _FileCountLines("C:\bkuplogs\mostrecent.txt") MsgBox(64, "LOG","There are " & $CountLines & " Lines in the file") $i=1 ; ; $file=fileopen("C:\bkuplogs\mostrecent.txt",0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop MsgBox(0, "Line read:", $line); so far so good If $result=stringinstr($line,"status") then run(@comspec "/c" & net send USER skipped found in file Elseif $result=stringinstr($line,"error") then run(@comspec "/c" & net send USER error found in file Elseif $result=stringinstr($line,"No media") then run(@comspec "/c" & net send USER error found in file endif ;...Etc. for lots of different different stings to search for Wend FileClose($file) the elseif's are looking for a coresponding IF statement, any ideas I think a case statement might work but I've no idea how to get it working Any help appreciated. Thanks Link to comment Share on other sites More sharing options...
Developers Jos Posted February 17, 2005 Developers Share Posted February 17, 2005 If $result = StringInStr($line, "status") Then Run(@ComSpec "/c net send USER skipped found in file") ElseIf $result = StringInStr($line, "error") Then Run(@ComSpec "/c net send USER error found in file ") ElseIf $result = StringInStr($line, "No media") Then Run(@ComSpec "/c net send USER error found in file") EndIf SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
phillip123adams Posted February 17, 2005 Share Posted February 17, 2005 the elseif's are looking for a coresponding IF statement, any ideas I think a case statement might work but I've no idea how to get it working<{POST_SNAPBACK}>Like JdeB said plus you need to remove the "$result = ", add "&" after @Comspec, and a space before "/c".If StringInStr($line, "status") Then Run(@ComSpec & " /c net send USER 'skipped found in file'") ElseIf StringInStr($line, "error") Then Run(@ComSpec & " /c net send USER 'error found in file'") ElseIf StringInStr($line, "No media") Then Run(@ComSpec & " /c net send USER 'error found in file'") EndIf Phillip Link to comment Share on other sites More sharing options...
hacksawbob Posted February 18, 2005 Author Share Posted February 18, 2005 Thanks for your help struggling to get my head round the new syntax, it requires thought which I'm not used to! 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