Gnat Posted May 22, 2008 Share Posted May 22, 2008 I have written a script that has several functions in it and one of them is causing the script to crash...Can somebody maybe point me in the right direction to either prevent the crash or to figure out what is actually causing the crash... The first couple of functions in the script just query AD for all servers in a given OU, then sorts them alphabetically, and then pulls out a certain number of those based on the server location. All of that works great! The function that is crashing is were I am attempting to scrape out of the Application event logs only Errors that happened on the previous day. After this runs for several servers (usually ~90) then it crashes with the following in the Application event log: Source: DrWatson Event ID: 4097 Description: The application, C:\TEMP\EventLogs.exe, generated an application error The error occurred on 05/22/2008 @ 13:47:48.731 The exception generated was c0000005 at address 7C81BD02 (ntdll!ExpInterlockedPopEntrySListFault) Here is the offending code: Func _AppLogCapture() $logfile = FileOpen('C:\Program Files\Scripts\EventLogs\applogs.txt', 2) $calc1date = _DateAdd('D', -1, _NowCalcDate()) $calc2date = _DateAdd('D', -2, _NowCalcDate()) $1daybefore = StringMid($calc1date, 6, 2) & '/' & StringRight($calc1date, 2) & '/' & StringLeft($calc1date, 4) $2daybefore = StringMid($calc2date, 6, 2) & '/' & StringRight($calc2date, 2) & '/' & StringLeft($calc2date, 4) $count = IniReadSection('C:\Program Files\Scripts\EventLogs\dallasservers.ini', 'Servers') For $i = 1 to $count[0][0] Step 1 $hostname = IniRead('C:\Program Files\Scripts\EventLogs\dallasservers.ini', 'Servers', $i, '') $applog = _EventLog__Open($hostname, 'Application') If $applog <> 0 Then $totalevt = _EventLog__Count($applog) For $j = $totalevt to 1 Step -1 $event = _EventLog__Read($applog, True, False) If $event[2] = $1daybefore and $event[7] = 1 Then FileWriteLine($logfile, $event[2] & ' ' & $event[3] & ',' & $event[6] & ',' & $event[8] & ',' & $event[9] & ',' & $event[10] & ',' & $event[11] & ',' & $event[12] & ',' & $event[13]) ElseIf $event[2] = $2daybefore Then ExitLoop EndIf Next _EventLog__Close($applog) EndIf Next FileClose($logfile) EndFunc; _AppLogCapture() Any/all help would be greatly appreciated... Link to comment Share on other sites More sharing options...
Kerros Posted May 22, 2008 Share Posted May 22, 2008 #AutoIt3Wrapper_run_debug_mode=Y That will should where you are in the script in the console. Add that at the top of your script. Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance. Link to comment Share on other sites More sharing options...
martin Posted May 22, 2008 Share Posted May 22, 2008 I have written a script that has several functions in it and one of them is causing the script to crash...Can somebody maybe point me in the right direction to either prevent the crash or to figure out what is actually causing the crash... The first couple of functions in the script just query AD for all servers in a given OU, then sorts them alphabetically, and then pulls out a certain number of those based on the server location. All of that works great! The function that is crashing is were I am attempting to scrape out of the Application event logs only Errors that happened on the previous day. After this runs for several servers (usually ~90) then it crashes with the following in the Application event log: Source: DrWatson Event ID: 4097 Description: The application, C:\TEMP\EventLogs.exe, generated an application error The error occurred on 05/22/2008 @ 13:47:48.731 The exception generated was c0000005 at address 7C81BD02 (ntdll!ExpInterlockedPopEntrySListFault) Here is the offending code: Func _AppLogCapture() $logfile = FileOpen('C:\Program Files\Scripts\EventLogs\applogs.txt', 2) $calc1date = _DateAdd('D', -1, _NowCalcDate()) $calc2date = _DateAdd('D', -2, _NowCalcDate()) $1daybefore = StringMid($calc1date, 6, 2) & '/' & StringRight($calc1date, 2) & '/' & StringLeft($calc1date, 4) $2daybefore = StringMid($calc2date, 6, 2) & '/' & StringRight($calc2date, 2) & '/' & StringLeft($calc2date, 4) $count = IniReadSection('C:\Program Files\Scripts\EventLogs\dallasservers.ini', 'Servers') For $i = 1 to $count[0][0] Step 1 $hostname = IniRead('C:\Program Files\Scripts\EventLogs\dallasservers.ini', 'Servers', $i, '') $applog = _EventLog__Open($hostname, 'Application') If $applog <> 0 Then $totalevt = _EventLog__Count($applog) For $j = $totalevt to 1 Step -1 $event = _EventLog__Read($applog, True, False) If $event[2] = $1daybefore and $event[7] = 1 Then FileWriteLine($logfile, $event[2] & ' ' & $event[3] & ',' & $event[6] & ',' & $event[8] & ',' & $event[9] & ',' & $event[10] & ',' & $event[11] & ',' & $event[12] & ',' & $event[13]) ElseIf $event[2] = $2daybefore Then ExitLoop EndIf Next _EventLog__Close($applog) EndIf Next FileClose($logfile) EndFunc; _AppLogCapture() Any/all help would be greatly appreciated...What happens if _EventLog__Read fails? It's not clear to me from the help. If it doesn't return an array then the code will have a problem. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Gnat Posted May 22, 2008 Author Share Posted May 22, 2008 #AutoIt3Wrapper_run_debug_mode=YThat will should where you are in the script in the console. Add that at the top of your script.Thanks, that is a new one to me, but the script is not crashing in the logic of it, but it is almost as though I am running out of memory for some reason.Any other ideas? Link to comment Share on other sites More sharing options...
Gnat Posted May 22, 2008 Author Share Posted May 22, 2008 What happens if _EventLog__Read fails? It's not clear to me from the help. If it doesn't return an array then the code will have a problem.If it fails, it returns a 0 (zero) and no array. Hence the reason for the "If $applog <> 0 Then" statement that checks that. Link to comment Share on other sites More sharing options...
martin Posted May 22, 2008 Share Posted May 22, 2008 (edited) If it fails, it returns a 0 (zero) and no array. Hence the reason for the "If $applog <> 0 Then" statement that checks that.No, that's IniRead, I said _EventLog__Read. it's not checked here expandcollapse popup $event = _EventLog__Read($applog, True, False) If $event[2] = $1daybefore and $event[7] = 1 Then [/code Edited May 22, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options... PsaltyDS Posted May 22, 2008 PsaltyDS MVPs 13.1k 1 Most Venerable Penguin Share Posted May 22, 2008 (edited) What happens if _EventLog__Read fails? It's not clear to me from the help. If it doesn't return an array then the code will have a problem. It returns an array for failure also, with [0] = False. Testing it might look like: $event = _EventLog__Read($applog, True, False) If $event[0] Then If $event[2] = $1daybefore And $event[7] = 1 Then FileWriteLine($logfile, $event[2] & ' ' & $event[3] & ',' & $event[6] & ',' & $event[8] & ',' & $event[9] & ',' & _ $event[10] & ',' & $event[11] & ',' & $event[12] & ',' & $event[13]) ElseIf $event[2] = $2daybefore Then ExitLoop EndIf Else MsgBox(16, "Error", "_EventLog__Read failed.") EndIf Edited May 22, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Gnat Posted May 27, 2008 Author Share Posted May 27, 2008 It returns an array for failure also, with [0] = False. Testing it might look like: $event = _EventLog__Read($applog, True, False) If $event[0] Then If $event[2] = $1daybefore And $event[7] = 1 Then FileWriteLine($logfile, $event[2] & ' ' & $event[3] & ',' & $event[6] & ',' & $event[8] & ',' & $event[9] & ',' & _ $event[10] & ',' & $event[11] & ',' & $event[12] & ',' & $event[13]) ElseIf $event[2] = $2daybefore Then ExitLoop EndIf Else MsgBox(16, "Error", "_EventLog__Read failed.") EndIf After turning on the debug_mode, I get the following error !>11:36:57 AutoIT3.exe ended.rc:-1073741819 >Exit code: -1073741819 Time: 436.543 Any help? Thanks 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