crm84
asked on
VB Script to Scan A Log File For Certain Strings and Output them to a Text File
Hi All,
Loving the site its been a fantastic experience so far, need a bit of help with a script im trying to compile but getting nowhere with,
The Scenario:
I have a log file which is generated by a Windows Server but is very clumsy to read, Every morning my team have to open this file and search for certain lines, this confirms whether or not a certain scheduled task has been successful or not, I want to make this much more streamlined, I would like a VB Script that can read the log file and scan it for certain sentences/messages and output that whole line into a seperate text file
I would like each occurance piped to a text file so that in essence its just a text file with the important bits I need
To summarize:
A vbs script to read Scheduledtasklog.txt and look for 4 strings
"task one was completed successfully"
"task two was completed successfully"
"task 3 was completed successfully"
"The Scheduled Task Fund Loader Was Successfull 948 Records were processed."
Each time it finds one export them to a seperate log file called clean.txt the lines may appear more than once and the last one will contain a different value every day
Only other thing worth noting is that each message has its own line in the big log file if that makes writing the script any easier?
Thanks guys, REALLY APPRECITATED
Loving the site its been a fantastic experience so far, need a bit of help with a script im trying to compile but getting nowhere with,
The Scenario:
I have a log file which is generated by a Windows Server but is very clumsy to read, Every morning my team have to open this file and search for certain lines, this confirms whether or not a certain scheduled task has been successful or not, I want to make this much more streamlined, I would like a VB Script that can read the log file and scan it for certain sentences/messages and output that whole line into a seperate text file
I would like each occurance piped to a text file so that in essence its just a text file with the important bits I need
To summarize:
A vbs script to read Scheduledtasklog.txt and look for 4 strings
"task one was completed successfully"
"task two was completed successfully"
"task 3 was completed successfully"
"The Scheduled Task Fund Loader Was Successfull 948 Records were processed."
Each time it finds one export them to a seperate log file called clean.txt the lines may appear more than once and the last one will contain a different value every day
Only other thing worth noting is that each message has its own line in the big log file if that makes writing the script any easier?
Thanks guys, REALLY APPRECITATED
ASKER
Hi there, alkimark,
I had checked this one to begin with and it doesnt have the option to repeat outputs, and would prefer VB and installing apps is restricted in our company,
RED tape everywhere!
I had checked this one to begin with and it doesnt have the option to repeat outputs, and would prefer VB and installing apps is restricted in our company,
RED tape everywhere!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tremendous 100% worked first time,
I could cry!
I could cry!
I know this is closed, but just wanted to mention that FINDSTR could probably do this easily as well, with a single command line. Something like:
FINDSTR /?
to get more info on the options it supports.
~bp
findstr /I /C:"task one was completed successfully" /C:"task two was completed successfully" /C:"task 3 was completed successfully" /C:"The Scheduled Task Fund Loader Was Successfull 948 Records were processed." inputfile.txt >errorfile.txt
You might want to play around with some of the options,but just wanted to pass this along in case it is ever something you can use. At a command line you can do:FINDSTR /?
to get more info on the options it supports.
~bp
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=24659