| View previous topic :: View next topic |
| Author |
Message |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Mon Sep 18, 2006 7:23 pm Post subject: file search. |
|
|
Hey guys
I need a non-eggdrop script that look into log files, I'm keeping 336 logs and previous year aswell, all text from channels, friends and college etc. just to keep the record for many stuff, i want a search tcl that will search for a masked word *De^KuS^* and give me the result. all help appreciated thanks. |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Mon Sep 18, 2006 8:43 pm Post subject: Re: file search. |
|
|
| honeybee wrote: | Hey guys
I need a non-eggdrop script that look into log files, I'm keeping 336 logs and previous year aswell, all text from channels, friends and college etc. just to keep the record for many stuff, i want a search tcl that will search for a masked word *De^KuS^* and give me the result. all help appreciated thanks. |
Non-eggdrop? Then this is the wrong place.
Learn about bash scripting maybe? _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Mon Sep 18, 2006 10:06 pm Post subject: |
|
|
| btw, you can use non-eggdrop tcl commands too, but i dont mind if its a bash command aswell, just needed help so i asked you guys. |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Mon Sep 18, 2006 10:27 pm Post subject: |
|
|
| honeybee wrote: | | i want a search tcl that will search .... |
Could you make your mind up? You either want a Tcl script or you don't.  _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Mon Sep 18, 2006 10:37 pm Post subject: |
|
|
| as its a SCRIPT REQUEST, nowhere is mentioned it should be a TCL SCRIPT to be request another i thought we usualy deal in tcls so I dont mind if its a tcl script and i have made up my mind honey ;) |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Mon Sep 18, 2006 11:15 pm Post subject: |
|
|
These forums deal with eggdrop only related scripts.
The inference is any request deals with the Tool Command Language only (Tcl); for anything outside of these forums' main focus you will have to look elsewhere.
| Quote: | | ... there is no guarantee of a response. |
_________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Tue Sep 19, 2006 3:21 am Post subject: |
|
|
| download the grep script from the archive and modify it to work on tclsh rather than eggdrop. |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Tue Sep 19, 2006 5:15 am Post subject: |
|
|
| Quote: | ##################################################################################
#
# Grep TCL Port
# http://perpleXa.net | http://dev.perpleXa.net
# #perpleXa on QuakeNet
# (C) perpleXa 2003-2004
#
# ------------------------------------------------------------------------------
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# ------------------------------------------------------------------------------
#
##################################################################################
#
# Usage: grep [-ivl num] resource pattern
# i - ignore upper/lower case distinctions during comparisons
# v - invert the sense of matching, to select non-matching lines
# l num - list max <num> amounts of lines (20 by default)
# resource - an absolute or relative path
# ie: /dev/null/*
# pattern - a perl compatible regular expression (PCRE)
# ie: #channel2|user9|Cleanup or [a-z]{7}\s[0-9]{2}
#
##################################################################################
bind pub n|- {$grep} grep
bind dcc n|- grep grep:dcc
proc grep {nickname hostname handle channel arguments} {
set arguments [grep:clean $arguments] ;# clean the arguments (better solution than [split])
set offset 0 ;# for optional parameters
set limit 20 ;# the default output limit
set option [join [lindex $arguments 0]] ;# first check
if {[regexp -- {^-(\S+)$} [lindex $arguments 0] tmp option]} {
if {[regexp -- {^([ivl]{1,3})$} $option]} {
if {[regexp -- {l} $option]} {
set offset 2
regexp -- {^([0-9]+)$} [join [lindex $arguments 1]] tmp limit
} else {
set offset 1
}
} else {
putquick "NOTICE $nickname :unknown option \"$option\""
return
}
}
if {[llength $arguments] < [expr $offset + 2]} {
putquick "NOTICE $nickname :Usage: grep \[-ivl num\] resource pattern"
putquick "NOTICE $nickname : i - ignore upper/lower case distinctions during comparisons"
putquick "NOTICE $nickname : v - invert the sense of matching, to select non-matching lines"
putquick "NOTICE $nickname : l num - list max <num> amounts of lines (20 by default)"
putquick "NOTICE $nickname : resource - an absolute or relative path"
putquick "NOTICE $nickname : ie: /dev/null/*"
putquick "NOTICE $nickname : pattern - a perl compatible regular expression (PCRE)"
putquick "NOTICE $nickname : ie: #channel2|user9|Cleanup or \[a-z\]\{7\}\\s\[0-9\]\{2\}"
return
}
set resource [join [lindex [grep:clean $arguments] $offset]]
set pattern [join [lrange $arguments [expr $offset + 1] end]]
set count 0
catch {[glob -- $resource]} error
if {[regexp -nocase -- {no files matched glob pattern "(.*?)"} $error]} {
puthelp "NOTICE $nickname :--- End of list - $count matches"
return
}
foreach file "[glob -- $resource]" {
if {[file isdirectory "$file"]} {continue}
set fp [open $file r]
while {![eof $fp]} {
gets $fp line
if {$count == $limit} {break}
switch -regexp -- $option {
{v} {
if {[regexp -- {i} $option]} {
catch {if {![regexp -nocase -- $pattern $line]} {puthelp "NOTICE $nickname :${file}:${line}" ; incr count}}
} else {
catch {if {![regexp -- $pattern $line]} {puthelp "NOTICE $nickname :${file}:${line}" ; incr count}}
}
}
default {
if {[regexp -- {i} $option]} {
catch {if {[regexp -nocase -- $pattern $line]} {puthelp "NOTICE $nickname :${file}:${line}" ; incr count}}
} else {
catch {if {[regexp -- $pattern $line]} {puthelp "NOTICE $nickname :${file}:${line}" ; incr count}}
}
}
}
}
close $fp
if {$count == $limit} {
puthelp "NOTICE $nickname :--- More than $limit hits, list truncated"
break
}
}
puthelp "NOTICE $nickname :--- End of list - $count matches"
}
proc grep:dcc {handle idx arguments} {
set arguments [grep:clean $arguments] ;# clean the arguments
set offset 0 ;# for optional parameters
set limit 500 ;# the default output limit
set option [join [lindex $arguments 0]] ;# first check
if {[regexp -- {^-(\S+)$} [lindex $arguments 0] tmp option]} {
if {[regexp -- {^([ivl]{1,3})$} $option]} {
if {[regexp -- {l} $option]} {
set offset 2
regexp -- {^([0-9]+)$} [join [lindex $arguments 1]] tmp limit
} else {
set offset 1
}
} else {
putidx $idx "unknown option \"$option\""
return
}
}
if {[llength $arguments] < [expr $offset + 2]} {
putidx $idx "Usage: grep \[-ivl num\] resource pattern"
putidx $idx " i - ignore upper/lower case distinctions during comparisons"
putidx $idx " v - invert the sense of matching, to select non-matching lines"
putidx $idx " l num - list max <num> amounts of lines (20 by default)"
putidx $idx " resource - an absolute or relative path"
putidx $idx " ie: /dev/null/*"
putidx $idx " pattern - a perl compatible regular expression (PCRE)"
putidx $idx " ie: #channel2|user9|Cleanup or \[a-z\]\{7\}\\s\[0-9\]\{2\}"
return
}
putcmdlog "\$${handle}\$ $::lastbind $arguments"
set resource [join [lindex [grep:clean $arguments] $offset]]
set pattern [join [lrange $arguments [expr $offset + 1] end]]
set count 0
catch {[glob -- $resource]} error
if {[regexp -nocase -- {no files matched glob pattern "(.*?)"} $error]} {
putidx $idx "--- End of list - $count matches"
return
}
foreach file "[glob -- $resource]" {
if {[file isdirectory "$file"]} {continue}
set fp [open $file r]
while {![eof $fp]} {
gets $fp line
if {$count == $limit} {break}
switch -regexp -- $option {
{v} {
if {[regexp -- {i} $option]} {
catch {if {![regexp -nocase -- $pattern $line]} {putidx $idx "${file}:${line}" ; incr count}}
} else {
catch {if {![regexp -- $pattern $line]} {putidx $idx "${file}:${line}" ; incr count}}
}
}
default {
if {[regexp -- {i} $option]} {
catch {if {[regexp -nocase -- $pattern $line]} {putidx $idx "${file}:${line}" ; incr count}}
} else {
catch {if {[regexp -- $pattern $line]} {putidx $idx "${file}:${line}" ; incr count}}
}
}
}
}
close $fp
if {$count == $limit} {
putidx $idx "--- More than $limit hits, list truncated"
break
}
}
putidx $idx "--- End of list - $count matches"
}
proc grep:clean {i} {
regsub -all -- \\\\ $i \\\\\\\\ i
regsub -all -- \\\[ $i \\\\\[ i
regsub -all -- \\\] $i \\\\\] i
regsub -all -- \\\} $i \\\\\} i
regsub -all -- \\\{ $i \\\\\{ i
regsub -all -- \\\" $i \\\\\" i
return $i
}
putlog "Script loaded: Grep TCL Port (C) 2004 perpleXa" |
This this script you refered but i've no idea how to change it to the one i need. |
|
| Back to top |
|
 |
|