OK, so let’s be clear. I don’t really have a programming background but I’ve muddled my way through creating a few PowerShell scripts to get some jobs done. Now I’ve got a much more complex thing that I’ve been asked to do, and I’m not sure how to go about it.<\/p>\n
Advertisement
What I need to do is search a log file (it’s a simple text file) for the word error and then pull about 5 lines previous to that error and put them in an email.<\/p>\n
Advertisement
If outputting to a new text file and sending that file as an attachment is easier that’s perfectly acceptable, I just need to be notified if a specific process outputs an error in the log file.<\/p>\n
Is this possible?<\/p>","upvoteCount":1,"answerCount":6,"datePublished":"2019-01-31T16:05:08.000Z","author":{"@type":"Person","name":"garyfthomas","url":"https://community.spiceworks.com/u/garyfthomas"},"suggestedAnswer":[{"@type":"Answer","text":"
OK, so let’s be clear. I don’t really have a programming background but I’ve muddled my way through creating a few PowerShell scripts to get some jobs done. Now I’ve got a much more complex thing that I’ve been asked to do, and I’m not sure how to go about it.<\/p>\n
What I need to do is search a log file (it’s a simple text file) for the word error and then pull about 5 lines previous to that error and put them in an email.<\/p>\n
If outputting to a new text file and sending that file as an attachment is easier that’s perfectly acceptable, I just need to be notified if a specific process outputs an error in the log file.<\/p>\n
Is this possible?<\/p>","upvoteCount":1,"datePublished":"2019-01-31T16:05:09.000Z","url":"https://community.spiceworks.com/t/need-to-extract-lines-from-a-log-file/695413/1","author":{"@type":"Person","name":"garyfthomas","url":"https://community.spiceworks.com/u/garyfthomas"}},{"@type":"Answer","text":"
Sure it’s possible, but let’s be clear, we’re happy to help, but not a script writing service<\/p>\n
Post what you’ve tried and where you’re stuck and we’ll help<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>