mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2006
Posts: 43
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Sep 2006
Posts: 43
I am looking for a script that will search my logs with a command i do then put the resulting lines in another file ie

/logsearch !qkick qkick
it will search all my logs for the first parameter (!qkick)and copy them to my second parameter + .txt (qkick) that will be in a different dir say X:\mirc\search\

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
There's probably better and faster ways of doing this.
Code:
alias logsearch {
  if !$2 { echo -a Insufficient parameters }
  else {
    if $exists($+($2,.txt)) {
      remove $+($2,.txt)
    }
    var %a = 1, %b = $findfile($logdir,*.*,0)
    while %a <= %b {
      var %file = $findfile($logdir,*.*,%a)
      if $read(%file,ntw,$+(*,$1,*)) {
        copy -a %file $+($2,.txt)
      }
      inc %a
    }
  }
}

Joined: Sep 2006
Posts: 43
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Sep 2006
Posts: 43
Thank you tried but
everytime I try it i get this
* /copy: unable to copy 'D:\mIRC' to 'D:\mIRC bak\bak\logs\#DM.20070814.log' (line 27, aliases.ini)

line 27 is
copy -a %file $+($2,.txt)

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Here's my approach, making heavy use of /filter
Type e.g. /logsearch today test
Code:
alias logsearch {
  if (!$2) { echo -a Insufficient parameters. Syntax: /logsearch matchword filename(without .txt) }
  else {
    var %matchword = $1, %lognum = $findfile($logdir,*.*,0)
    echo -ga Looking up %lognum logfiles for $qt($1) ....
    window -h @logfilter
    window -h @logbuffer
    noop $findfile($logdir,*.*,0,logfilter $shortfn($1-) %matchword)
  }
  window -c @logbuffer
  if ($line(@logfilter,1)) {
    if (!$isdir($qt($+($mircdir,logsearch)))) { mkdir $qt($+($mircdir,logsearch))) }
    filter -wfc @logfilter $qt($+($mircdir,logsearch\,$2,.txt))
    run $qt($+($mircdir,logsearch\,$2,.txt))
  }
  else { echo -ga Sorry, found no matches of $qt(%matchword) in your %lognum logfiles. }
  window -c @logfilter
}

alias -l logfilter {
  filter -fwn $1 @logbuffer $+(*,$2 ,*)
  if ($filtered) {
    aline @logfilter $str(-,20) File $longfn($1) : $v1 $iif(($v1 == 1),match,matches) of $qt($2) $+ : $str(-,20)
    filter -ww @logbuffer @logfilter
    aline @logfilter $chr(9)
    clear @logbuffer
  }
}


Last edited by Horstl; 17/08/07 10:38 AM.
Joined: Sep 2006
Posts: 43
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Sep 2006
Posts: 43
Thank you tried some thing i knew was in a log and it said this
Looking up 145 logfiles for "!qkick" ....
* /filter: unable to open 'D:\mIRC' (line 33, aliases.ini)
line 33 is
filter -fwn $1 @logbuffer $+(*,$2 ,*)

Last edited by McOwnage; 17/08/07 09:45 AM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I did a little edit, maybe it's working now.
If you type "//echo -a $logdir", is this directory your main log directory?

Joined: Sep 2006
Posts: 43
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Sep 2006
Posts: 43
D:\mIRC bak\logs\

that is what it replied that is my log dir

Joined: Sep 2006
Posts: 43
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Sep 2006
Posts: 43
also i paseded it into alias did not work
i also made a logse.mrc and loaded it nope did not work the first time i took out the
alias in front of logsearch and filter

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The problem is about folder names that contain spaces. Hopefully... I fixed this now smile

Joined: Sep 2006
Posts: 43
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Sep 2006
Posts: 43
all i get is LOGSEARCH Unknown command

i tried /logsearch !qkick qkick

how do i load this ? just paste it in alias or copy it into a mrc file and load it i trierd it both ways and does not work

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Open a new remote file (Alt-R > select tab "remote" > menu "file" > "new"), then paste the code into that blanc file and save this new file (menu "file" > "save as")

there was a minor error, thus pasting the script again:
Code:
alias logsearch {
  if (!$2) { echo -a Insufficient parameters. Syntax: /logsearch matchword filename(without .txt) }
  else {
    var %matchword = $1, %lognum = $findfile($logdir,*.*,0)
    echo -ga Looking up %lognum logfiles for $qt($1) ....
    window -h @logfilter
    window -h @logbuffer
    noop $findfile($logdir,*.*,0,logfilter $shortfn($1-) %matchword)
    window -c @logbuffer
    if ($line(@logfilter,1)) {
      if (!$isdir($qt($+($mircdir,logsearch)))) { mkdir $qt($+($mircdir,logsearch))) }
      filter -wfc @logfilter $qt($+($mircdir,logsearch\,$2,.txt))
      run $qt($+($mircdir,logsearch\,$2,.txt))
    }
    else { echo -ga Sorry, found no matches of $qt(%matchword) in your %lognum logfiles. }
    window -c @logfilter
  }
}

alias -l logfilter {
  filter -fwn $1 @logbuffer $+(*,$2 ,*)
  if ($filtered) {
    aline @logfilter $str(-,20) File $longfn($1) : $v1 $iif(($v1 == 1),match,matches) of $qt($2) $+ : $str(-,20)
    filter -ww @logbuffer @logfilter
    aline @logfilter $chr(9)
    clear @logbuffer
  }
}


Last edited by Horstl; 18/08/07 06:54 AM.
Joined: Sep 2006
Posts: 43
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Sep 2006
Posts: 43
ok Thanks allot works but only on that days log files can it search all log files?

Last edited by McOwnage; 18/08/07 07:51 AM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
It should search all files that are located in your $logdir (even if the file extension is not .log - which could be criticized cool )

Joined: Sep 2006
Posts: 43
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Sep 2006
Posts: 43
DOH i forgot I moved my old logs lol

Thank you so much


Last edited by McOwnage; 18/08/07 09:12 AM.

Link Copied to Clipboard