• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Scripting file transfer from logfile

Joined
Jan 28, 2001
Messages
843
Calling all [H]Coders...

I'm in the middle of a huge project to migrate terabytes of data and need to find a way to parse a log file in the following manner.

Every line of the log file looks like this : (Some information changed)

12/17/2005 00:15:18 - DBG - 00104: FileCopyContentsOverlapped(I:\Shared\DATA\XXX_XX\XXXXXX\XXXXX\v321.ent\XX-XXXXX\dwnlds.xx\xxxxxx\xxxxxxx for P4 Processors\STAGE\Components\xxxxxx.java.javavm.javatools\x.x.x.x.x\x\DataFiles\Expanded\jis\patch\c++\login.tar), Access is denied.

The information I need to get is the path you see within the () and then format it into a copy command of the following nature :

copy \\<server>\ (PATH FROM LOG MINUS I:\SHARED\) (WHOLE PATH FROM LOGFILE)

I'm terrible at parsing log files in scripts. The beginning of the parens is ALWAYS at the same column of the line, but clearly the end will be different depending on the file path.

If anyone has any ideas how to do this or even point me in the right direction, I would be forever in your debt.

This script will need to run on a windows platform.
 
If your parsing this logfile on a UNIX-like system (e.g. linux, FreeBSD, cygwin) then you could use awk/sed to parse the data out. This works with your example log file on my FreeBSD system:

Code:
awk 'BEGIN { FS = "[\(\)]" } /FileCopyContentsOverlapped/{print $2}' < logfile | sed -e 's/^I:\\//g'
 
Ok, let's say you have the following 2 lines saved as "parselog.cmd" :

Code:
@echo off
for /F "delims=() tokens=2" %%A in (%1) do (echo copy "\\%2\%%A" "%%A")

...then you can do:

parselog C:\somefile.log myserver > c:\copycmds.cmd

To write the file C:\copycmds.cmd.

Note that it still has the "I:\Shared" after the "\\server\" but hey, I can't do all the work for you!

This should work under Win2K/XP/2003 Server, etc
 
Back
Top