grep.itcl:
Code:
if {[llength $args]!=2} {
iputs "Syntax: SITE GREP <search_string> <logfile> "
iputs "<logfile>: Error, ioFTPD, SysOp, SystemError or xferlog"
return
}
set lookup [lindex $args 0]
if {[lindex $args 1]=="xferlog"} {
set filename "../logs/[lindex $args 1]"
} else {
set filename "../logs/[lindex $args 1].log"
}
iputs -nobuffer "Looking for '$lookup' in $filename"
set ferror [catch {set fp [open $filename r]}]
if {!$ferror} {
set dc 0
while {![eof $fp]} {
set line [gets $fp]
if {[string match -nocase "*$lookup*" $line]} {
iputs -nobuffer $line
incr dc
}
}
close $fp
iputs "$dc entries found"
} else {
iputs "Error opening '$filename'."
}
[Scripts]
GREP = TCL ..\scripts\grep.itcl
Code:
[11:22:49] [L] site grep Mouton xferlog
[11:22:49] [L] 200-Looking for 'Mouton' in ../logs/xferlog
[11:22:49] [L] 200-Wed Nov 19 16:01:13 2003 31 64.221.14.121 5492588 /!ioftpd/logs/ioFTPD.log b _ i r Mouton ftp 1 gb l
...
[11:22:49] [L] 200-21 entries found
[11:22:49] [L] 200 Command successful.