frankpintosr Posted April 15, 2008 Share Posted April 15, 2008 (edited) I am trying to have the script read an existing file, and if it finds the string (status) = 0 then display a msg, if it does not find that string, display another msg. This string is always on the last lane, so if you know a way to look at the last line only, that would be great. I have been searching the whole file. Here's my code. PS, I am a total newbee. ;Variables $Computername = EnvGet("computername") $Welcome = 0 ;$StorageServers = $CMDLineRaw $StorageServers = "server" $logfile = "C:\" & $Computername & ".log" FileOpen ($logfile,0) ;Check if file opened for reading OK If $logfile = -1 Then MsgBox (0, "Error", "Unable to open log file.") Exit EndIf While 1 $line = FileReadLine($logfile) If @error = -1 Then ExitLoop if StringInStr($line, "(status)") > 0 Then $var = StringRight($line, 1) EndIf WEnd If $var = "0" Then MsgBox(0, "Process", "sucessfully captured.", 10) Else MsgBox (0, "Process", "data migration CAN NOT BE CONFIRMED, please check C:\" & $Computername & ".log for errors during the process.") EndIf FileClose($logfile) Edited April 15, 2008 by frankpintosr Link to comment Share on other sites More sharing options...
weaponx Posted April 15, 2008 Share Posted April 15, 2008 (edited) Perhaps... #include <File.au3> $LastLine = _FileCountLines ( $sFilePath ) FileReadLine($sFilePath, $LastLine) Edited April 15, 2008 by weaponx Link to comment Share on other sites More sharing options...
frankpintosr Posted April 16, 2008 Author Share Posted April 16, 2008 Thank you, that did the trick with some slight tweaking in other areas of my script. Thanks a bunch!! Perhaps...#include <File.au3>$LastLine = _FileCountLines ( $sFilePath )FileReadLine($sFilePath, $LastLine) 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