Hey John Dalton,
Your questions: How can I count the number of rows in the db2diag.log
file? How can I delete certain rows in the db2dialog file? Also, you
said you were running DB2 version 8.2, Fixpack 7, on Windows 2003 and
you db2diag.log file 34 KB in size. Well, John, the code (WSH scripts)
below may be of help to you. Also, you are encouraged to improve it!
Hehe.
This code below counts the number of lines in the db2diag.log file.
Save this code in "count_lines.vbs"
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("G:\Program
Files\IBM\SQLLIB\DB2\db2diag.log", 1)
DO Until objFile.AtEndOfStream
objFile.ReadLine
i = i + 1
Loop
objFile.Close
Wscript.Echo(i)
To run it, click on the icon (count_lines.vbs)
This code below deletes lines 1-4 in the db2diag.log file.
Save this code in "delete_lines.vbs"
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, fi, fo, nLines, sInFile, sOutFile, j
j = 0
sInFile = "D:\Program Files\IBM\SQLLIB\DB2\db2diag.log"
sOutFile = "D:\Program Files\IBM\SQLLIB\DB2\db2diag.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fi = fso.OpenTextFile(sInFile, ForAppending)
nLines = fi.Line
fi.close
Set fi = fso.OpenTextFile(sInFile, ForReading)
Set fo = fso.OpenTextFile(sOutFile, ForWriting, true)
for i = 1 to nLines - 1
if i >= 1 and i <= 4 then
fo.Writeline fi.readline
j = j + 1
else
fi.readline
end if
next
fi.close
fo.close
wsh.echo "Done:", nLines - 2, "lines read."
wsh.echo "Done:", j, "lines written."
To run it, click on the icon (delete_lines.vbs)
Have a great Day!
Please take a few minutes to provide feedback on the quality of service you received. The Department of Education values your feedback as a customer. Commissioner John L. Winn is committed to continuously assessing and improving the level and quality of services provided to you by Department staff. Simply use the link below. Thank you in advance for completing the survey.
http://data.fldoe.org/cs/default.cfm?staff=Ed.[Email address protected]
DB2 & UDB email list listserv db2-l LazyDBA home page