RestrictedUser Posted March 10, 2019 Share Posted March 10, 2019 (edited) Hello AutoIt Scriptwriters! 👋❤️ The log file of one of Server Managers is opened and now is writing by Server Manager Log file contents are: 2019-03-21 Error!: Syntax not found! 2019-03-21 Error! Specified language not found! How can i make a script to check the log file every 1 second, if log file writes new line, then send a MsgBox that contains last written line by Server Manager? Edited March 10, 2019 by Colduction Link to comment Share on other sites More sharing options...
maniootek Posted March 10, 2019 Share Posted March 10, 2019 Do you have any code you tried so far? Link to comment Share on other sites More sharing options...
RestrictedUser Posted March 10, 2019 Author Share Posted March 10, 2019 6 minutes ago, maniootek said: Do you have any code you tried so far? Yeah; $Read = FileReadLine(@DesktopDir & "\new.log") MsgBox(64, "", $Read) Link to comment Share on other sites More sharing options...
Exit Posted March 10, 2019 Share Posted March 10, 2019 Use FileGetSize() in a loop with sleep(1000) to get filesize. If it changes, open the file for read, position to EOF - deltasize with filesetpos() Fileread() and display in messagebox RestrictedUser 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
RestrictedUser Posted March 10, 2019 Author Share Posted March 10, 2019 15 minutes ago, Exit said: Use FileGetSize() in a loop with sleep(1000) to get filesize. If it changes, open the file for read, position to EOF - deltasize with filesetpos() Fileread() and display in messagebox Thanks bro! If you write these codes, it's better😓 Link to comment Share on other sites More sharing options...
Exit Posted March 10, 2019 Share Posted March 10, 2019 2 minutes ago, Colduction said: If you write these codes, it's better😓 I really don't like spoonfeeding. Roll your own and show us the result 😉 FrancescoDiMuro 1 App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
RestrictedUser Posted March 10, 2019 Author Share Posted March 10, 2019 Just now, Exit said: I really don't like spoonfeeding. Roll your own and show us the result 😉 Ok bro, thanks for your care Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 10, 2019 Share Posted March 10, 2019 (edited) 7 minutes ago, Colduction said: If you write these codes, it's better😓 Spoiler It's really annoying to keep seeing people who, even if pointed to a Forum etiquette multiple times, keep asking for code without putting minimum effort in what they are trying to do. Annoying and sad at the same time. Ffs, do something and stop asking for code. Edited March 10, 2019 by FrancescoDiMuro Exit 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
RestrictedUser Posted March 10, 2019 Author Share Posted March 10, 2019 (edited) 2 minutes ago, FrancescoDiMuro said: Hide contents It's really annoying to keep seeing people who, even if pointed to a Forum etiquette multiple times, keep asking for code without pugting minimum effort in what they are trying to do. Annoying and sad at the same time. Ffs, do something and stop asking for code. Excuse me my friend, but I'm noobie I've just started AutoIt scripting in last week Edited March 10, 2019 by Colduction Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 10, 2019 Share Posted March 10, 2019 @Colduction Sure, but that's not an excuse. If you keep asking for code without putting any effort trying to do and, most important, to understand what you are trying to do, then you'll never understand what you are doing, and you'll always need someone who spoon the code for you (even if it's not a good thing to do here). Do something, and if you need help, then post your code here. RestrictedUser 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
RestrictedUser Posted March 10, 2019 Author Share Posted March 10, 2019 39 minutes ago, FrancescoDiMuro said: @Colduction Sure, but that's not an excuse. If you keep asking for code without putting any effort trying to do and, most important, to understand what you are trying to do, then you'll never understand what you are doing, and you'll always need someone who spoon the code for you (even if it's not a good thing to do here). Do something, and if you need help, then post your code here. Thanks bro, Okay❤️👌 Link to comment Share on other sites More sharing options...
Bilgus Posted March 10, 2019 Share Posted March 10, 2019 Actually you can just keep the file handle open and use readfile on it @extended will contain the characters read like so.. ;Pseudo code Global $g_sFile = "C:\Logfile.txt" Global $g_hFile = FileOpen($g_sFile) ;Read Permissions Global $g_iRetries = 60 ;Exits after 60 seconds with no new data If $g_hFile < 0 Then MsgBox(0, "Error", "Can't open " & $g_sFile) Exit EndIf Global $g_sRead = "" While $g_iRetries > 0 $g_sRead &= FileRead($g_hFile, -1) ;@extended is set to the number of bytes/characters returned If @extended = 0 Then $g_iRetries -= 1 sleep(1000) Else ;There is new data!! ConsoleWrite($g_sRead & @CRLF) $g_sRead = "" $g_iRetries = 60 ; reset wait count Endif WEnd FileClose($g_hFile) RestrictedUser 1 Link to comment Share on other sites More sharing options...
Nine Posted March 10, 2019 Share Posted March 10, 2019 lol, there will always be someone who is giving fishes... Earthshine and FrancescoDiMuro 1 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
RestrictedUser Posted March 10, 2019 Author Share Posted March 10, 2019 1 hour ago, Bilgus said: Actually you can just keep the file handle open and use readfile on it @extended will contain the characters read like so.. ;Pseudo code Global $g_sFile = "C:\Logfile.txt" Global $g_hFile = FileOpen($g_sFile) ;Read Permissions Global $g_iRetries = 60 ;Exits after 60 seconds with no new data If $g_hFile < 0 Then MsgBox(0, "Error", "Can't open " & $g_sFile) Exit EndIf Global $g_sRead = "" While $g_iRetries > 0 $g_sRead &= FileRead($g_hFile, -1) ;@extended is set to the number of bytes/characters returned If @extended = 0 Then $g_iRetries -= 1 sleep(1000) Else ;There is new data!! ConsoleWrite($g_sRead & @CRLF) $g_sRead = "" $g_iRetries = 60 ; reset wait count Endif WEnd FileClose($g_hFile) Thanks brother, Thanks🎉🍻 You've made my day🎊❤️ Link to comment Share on other sites More sharing options...
RestrictedUser Posted April 20, 2019 Author Share Posted April 20, 2019 (edited) On 3/11/2019 at 1:14 AM, Bilgus said: ;Pseudo code Global $g_sFile = "C:\Logfile.txt" Global $g_hFile = FileOpen($g_sFile) ;Read Permissions Global $g_iRetries = 60 ;Exits after 60 seconds with no new data If $g_hFile < 0 Then MsgBox(0, "Error", "Can't open " & $g_sFile) Exit EndIf Global $g_sRead = "" While $g_iRetries > 0 $g_sRead &= FileRead($g_hFile, -1) ;@extended is set to the number of bytes/characters returned If @extended = 0 Then $g_iRetries -= 1 sleep(1000) Else ;There is new data!! ConsoleWrite($g_sRead & @CRLF) $g_sRead = "" $g_iRetries = 60 ; reset wait count Endif WEnd FileClose($g_hFile) excuseme, this script writes even old datas that already written by different program can you guide me to only get new data? Edited April 20, 2019 by Colduction Link to comment Share on other sites More sharing options...
Matt_Murdoch Posted April 21, 2019 Share Posted April 21, 2019 So modify it. You already got your free fish 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