Jump to content

Parse through log file


Recommended Posts

Hi,

I ran a remote program on 180 computers and logged the output to a log file with paexec.  I'm trying to parse through the log file to see which computers launched the program successfully and record the computer name but I'm not sure how to go about it. 

I can successfully open the log file, read it but not sure how to start separating the data.

I've attached the log file, basically every computer entry in the log file for a new computer starts with "Connecting to <computername>..." I was thinking about using that as the start and stop point for retrieving the end results.  Anything with a "returned 0" is a success, everything is a fail.

Any help is much appreciated.

testlogfile.txt

Link to comment
Share on other sites

This example appears to work on your Test log file.

;#include <Array.au3>
#include <File.au3>

Local $sFileName = "testlogfile.txt"
$a = StringRegExp(FileRead($sFileName), "Connecting to ([^\.]+).*\v+Starting PAExec.+\v+Copying.+\v+.+returned 0", 3)

;_ArrayDisplay($a)
_FileWriteFromArray("SuccessComputers.txt", $a) ; Record results
ShellExecute("SuccessComputers.txt")

 

Link to comment
Share on other sites

also, avoiding regex

#include<array.au3>

$aSplit = stringsplit(fileread("testlogfile.txt") , @LF , 2)
$aFound = _ArrayFindAll($aSplit , "returned 0" , 0 ,0 ,0 ,1)

for $i = 0 to ubound($aFound) - 1
    $aFound[$i] = stringtrimleft(stringtrimright($aSplit[$aFound[$i] -4] , 4) , 14)
Next

_ArrayDisplay($aFound)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...