Link to home
Start Free TrialLog in
Avatar of samiam41
samiam41Flag for United States of America

asked on

Insert host name into master log file relating to data being copied

Hi Experts.  In what will likely be the last upgrade to this script for a little while, I would like to insert the name of the server that the data being copied from relates to, using this script.
@echo off
setlocal enabledelayedexpansion
set CentralLog=D:\Temp\test_Central.log
if "%~1"=="" (
	set FindDate=
	set /p FindDate=Enter date to search: 
) else (
	set FindDate=%~1
)
if "%FindDate%"=="" goto :eof
set CopyBegin=SCHEDULEREC STATUS BEGIN
set CopyEnd=SCHEDULEREC STATUS END
for /f "tokens=1 delims=[]" %%a in ('type "%~f0" ^| find /i /n "[DATA]"') do set DataStart=%%a
for /f "skip=%DataStart% delims=" %%a in ('type "%~f0"') do (
	echo Processing '%%a' ...
	set /a CopyFound = 0
	set /a Copy = 0
	for /f "delims=" %%b in ('type "%%a" ^| findstr.exe "^%FindDate%"') do (
		set Line=%%b
		if !Copy!==0 (
			if not "!Line!"=="!Line:%CopyBegin%=!" (
				set /a CopyFound = 1
				set /a Copy = 1
				>>"%CentralLog%" echo !Line!
			)
		) else (
			>>"%CentralLog%" echo !Line!
			if not "!Line!"=="!Line:%CopyEnd%=!" (
				set /a Copy = 0
			)
		)
	)
	if !CopyFound!==0 (
		echo No match found in '%%a'.
	)
)
goto :eof

[DATA]
\\w2k3ps01\d$\Program Files\Tivoli\TSM\baclient\dsmsched.log

Open in new window


When the data is copied from multiple servers, there is no reference in the master log file as to which server the data is coming from.  I need to add this to make the log file useful.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of samiam41

ASKER

THAT IS SOOO COOL!!

Hahahaha!!  That's perfect!  Thank you so much for your help!

~Aaron