Tentaal Posted January 2, 2007 Share Posted January 2, 2007 Hi, I'm looking for a way to watch a text file in real time. I want to make a small tool that check log files in real time in a windows. Thanks in advance for any help! Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 2, 2007 Share Posted January 2, 2007 It is possible. The easiest to implement way would be to keep a copy in memory, and read the text file every loop. Compare it to the original. You could also check the last write time. That would be the most efficient in my opinion. Link to comment Share on other sites More sharing options...
Tentaal Posted January 2, 2007 Author Share Posted January 2, 2007 I understand this : $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop MsgBox(0, "Char read:", $chars) Wend FileClose($file) But... I dont get the way to open a Windows and display the text inside it. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 2, 2007 Share Posted January 2, 2007 Ok, I see that I missed something. Just make a GUI and put a label or edit into the GUI. Instead of reading a character at a time and putting it into a MsgBox, put them all into a string. While 1 $text += FileRead($file, 1) If @error = -1 Then ExitLoop WEnd MsgBox(0, "", $text) Link to comment Share on other sites More sharing options...
Tentaal Posted January 2, 2007 Author Share Posted January 2, 2007 (edited) Mmm. this put the text on the GUI but show only one lineIt does'nt make a return (CR)...#include <GUIConstants.au3>$file = FileOpen("test.txt", 0); Check if file opened for reading OKIf $file = -1 Then MsgBox(0, "Error", "Unable to open file.") ExitEndIfGUICreate("Test", 600, 300)GUISetState(@SW_SHOW)While 1$line = FileReadLine($file)GUICtrlCreateEdit ($line , 10, 10 , 590 , 290 )sleep(2000)If @error = -1 Then ExitLoopWEnd Edited January 2, 2007 by Tentaal Link to comment Share on other sites More sharing options...
Zedna Posted January 2, 2007 Share Posted January 2, 2007 Mmm. this put the text on the GUI but show only one line It does'nt make a return (CR)... Try this (not tested): #include <GUIConstants.au3> $file = FileOpen("test.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf GUICreate("Test", 600, 300) $edit = GUICtrlCreateEdit ($line , 10, 10 , 590 , 290 ) GUISetState(@SW_SHOW) While 1 $data = FileRead($file) GUICtrlSetData ($edit, $data) If @error = -1 Then ExitLoop sleep(2000) WEnd FileClose($file) ;finally show whole result While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ptrex Posted January 4, 2007 Share Posted January 4, 2007 @all The only good way to monitor Logs is using the "MS LogParser SQL Engine in AutoIT" This was specially designed for this purpose. See more info in my signature. Enjoy !! ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
/dev/null Posted January 4, 2007 Share Posted January 4, 2007 TailRW http://www.autoitscript.com/forum/index.php?showtopic=31464 __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * 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