Background:
I am writing a script to e-mail Server down events and Service failure events to a select group of admins for a specified list of servers. I write the results of my WMI query to a text file. In order to not recieve multiple e-mails for the same event I test for the existence of my text file. This part works beautifully. The script is self healing in that it deletes the text file when all checks return to normal.
Problem:
The question has been raised as to what happens if a second failure arises while the script is operating in it's error state. I am trying to minimize file use and general overhead as this script runs every five minutes. I wanted to read the results of the file if it exists into an array and then compare the results of my query to the array so that it would send an additional e-mail if a second (or third, etc.) event occurred before the status returns to normal. I use the readline function to return each line of the text file and then use Split to separate each line into it's requisite pieces. This works fine. However, when I try to pass these results to another array I get a Type Mismatch error. I have tried declaring the array as both "Dim variable" and "Dim variable()". I recieve an error either way. I have tried cStr and cVar against the array that is loaded by split and recieve other errors.
I am relatively new to scripting and I am hoping I am overlooking something simple. The only work around I can come up with is to rename the file and read it over and over again for each check. This doesn't seem overly efficient to me. Any suggestions as to how to rectify this or a better way to do it would be highly appreciated. Thanks.
Mike
I am writing a script to e-mail Server down events and Service failure events to a select group of admins for a specified list of servers. I write the results of my WMI query to a text file. In order to not recieve multiple e-mails for the same event I test for the existence of my text file. This part works beautifully. The script is self healing in that it deletes the text file when all checks return to normal.
Problem:
The question has been raised as to what happens if a second failure arises while the script is operating in it's error state. I am trying to minimize file use and general overhead as this script runs every five minutes. I wanted to read the results of the file if it exists into an array and then compare the results of my query to the array so that it would send an additional e-mail if a second (or third, etc.) event occurred before the status returns to normal. I use the readline function to return each line of the text file and then use Split to separate each line into it's requisite pieces. This works fine. However, when I try to pass these results to another array I get a Type Mismatch error. I have tried declaring the array as both "Dim variable" and "Dim variable()". I recieve an error either way. I have tried cStr and cVar against the array that is loaded by split and recieve other errors.
I am relatively new to scripting and I am hoping I am overlooking something simple. The only work around I can come up with is to rename the file and read it over and over again for each check. This doesn't seem overly efficient to me. Any suggestions as to how to rectify this or a better way to do it would be highly appreciated. Thanks.
Mike