This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

file search.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

file search.

Post by honeybee »

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.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Re: file search.

Post by Alchera »

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
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

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.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

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. :D
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

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 ;)
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

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.
... there is no guarantee of a response.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

download the grep script from the archive and modify it to work on tclsh rather than eggdrop.
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

##################################################################################
#
# 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.
Post Reply