| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Caller Dropped Carrier script |
Here's a short script I wrote to read in a Maximus log file and separate those
annoying "Caller dropped carrier" sessions caused by internet port scans.
Filename: proc_cdc.vbs
Shell: Cscript, VBScript
Platform: Any operating system with Windows Scripting Host (WSH) installed eg.
Windows XP/2k/2k+[3,8]/Vista/7. You can get WSH for Windows9x & NT.
Purpose: All BBS call log entries with only "Caller dropped
carrier" in them
are filtered to separate files eg. %filename%.cdc & %filename%.log.
Assumes: The log files to be processed do NOT have *.log or *.cdc extension.
The system for which this script was written writes Maximus log files
to "node%1.tmp" where %1 is the node number.
Input: Any Maximus log file
Output: Deletes input file and creates *.cdc (for Caller Dropped Carrier)
and *.log (Other).
proc_cdc.vbs:
===============================================================================
Option Explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 8, CreateIfNotExist = 1
Const DEBUGGING = False
Dim objFileLogfileCdc
Dim objFileLogfileNode
Dim objFileLogfileNodeTmp
Dim strLogfileNode
Dim strLogfileNodeTmp
Dim strLine, strLineBuf, strLineBufType
Dim intPos
Dim intLineCount
Dim i
' Get node%1.tmp filename
strLogfileNodeTmp = WScript.Arguments(0)
' Get node%1.tmp base filename
intPos = InStr(1, strLogfileNodeTmp, ".", vbTextCompare)
strLogfileNode = Left(strLogfileNodeTmp, intPos - 1)
' Open files for reading and/or appending
Set objFileLogfileNodeTmp = OpenTextFile(strLogfileNodeTmp, ForReading)
Set objFileLogfileNode = OpenTextFile(strLogfileNode &
".log", ForAppending)
Set objFileLogfileCdc = OpenTextFile(strLogfileNode &
".cdc", ForAppending)
'
' Process node%1.tmp
'
Wscript.Echo WScript.ScriptFullName & " running ..."
intLineCount = 0
strLineBufType = ".log" ' Initialise default line buffer type
Do While objFileLogfileNodeTmp.AtEndOfStream True
strLine = objFileLogfileNodeTmp.ReadLine
strLineBuf = strLineBuf & strLine & vbNewLine
If RegExpTest("MAX Begin, v3.01", strLine) Then
' Reset line count and string buffer at beginning-of-call
strLineBuf = strLine & vbNewLine
intLineCount = 1
' An empty line signals end-of-call so flush string buffer to the correct log file
ElseIf RegExpTest("^$", strLine) And intLineCount > 1 Then
Select Case strLineBufType
Case ".log"
If DEBUGGING Then
Wscript.Echo "Writing to " & strLogfileNode &
".log:"
Wscript.Echo strLineBuf
End If
objFileLogfileNode.WriteLine strLineBuf
strLineBuf = Null
intLineCount = 0
Case ".cdc"
If DEBUGGING Then
Wscript.Echo "Writing to " & strLogfileNode &
".cdc:"
Wscript.Echo strLineBuf
End If
objFileLogfileCdc.WriteLine strLineBuf
strLineBufType = ".log" ' Reset back to ".log"
just to be sure
strLineBuf = Null
intLineCount = 0
End Select
End If
' Check every third line for CDC
If intLineCount = 3 Then
If RegExpTest("MAX Caller dropped carrier", strLine) Then
strLineBufType = ".cdc"
Else
strLineBufType = ".log"
End If
End If
intLineCount = intLineCount + 1
If DEBUGGING Then
If i > 100 Then ' Look at this number of lines only
Exit Do
End If
I = i+1
End If
Loop
objFileLogfileCdc.Close
objFileLogfileNode.Close
objFileLogfileNodeTmp.Close
If Not DEBUGGING Then
DeleteFile(strLogfileNodeTmp)
End If
Function OpenTextFile(strPathFilename, intMode)
Dim fso, fd
Set fso = CreateObject("Scripting.FileSystemObject")
Set fd = fso.OpenTextFile(strPathFilename, intMode, CreateIfNotExist)
Set OpenTextFile = fd
End Function
Function RegExpTest(patrn, strng)
Dim regEx, retVal ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case sensitivity.
retVal = regEx.Test(strng) ' Execute the search test.
RegExpTest = retVal
End Function
Sub DeleteFile(strPathFilename)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strPathFilename)
f.Delete
End Sub
===============================================================================
Example RUNBBS.BAT:
===============================================================================
set LOGFILE_NODE=node%1.tmp
max -n%1 -l%LOGFILE_NODE% -e0 -b%2 -s%3 %4 %5 %6 %7 %8 %9
if errorlevel 255 goto UndefError
if errorlevel 16 goto Error
if errorlevel 12 goto EchoMail
if errorlevel 11 goto NetMail
if errorlevel 10 goto localmail
if errorlevel 5 goto Aftercall
if errorlevel 4 goto Error
if errorlevel 3 goto Error
if errorlevel 2 goto Done
if errorlevel 1 goto altx
:Done
rem ; Clean up log file by removing "Caller dropped carrier"
cscript %max%\scripts\proc_cdc.vbs %LOGFILE_NODE%
===============================================================================
--- Maximus 3.01
* Origin: Xaragmata / Adelaide SA telnet://xaragmata.mooo.com (3:800/432)SEEN-BY: 261/38 633/104 260 267 640/954 690/682 734 712/0 313 848 800/7 432 SEEN-BY: 800/812 896 @PATH: 800/432 633/260 712/848 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.