mIRC Home    About    Download    Register    News    Help

Print Thread
#93251 08/08/04 01:55 AM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
Okay so now I have it so I can write all the ips into a txt, each one on its own line. Im stuck tho on one point. I am trying to loop through the txt finding duplicates here itll be easier to show what im trying to do
:Example Text File
127.0.0.1
192.163.0.101
192.163.0.102
127.0.0.1
Now lets say someone does !checkclones it would output
Clones: 127.0.0.1 (2)
or something i just cant think of how to do it without some messy if then loop comparing each line

#93252 08/08/04 03:23 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
You're going to have to loop one way or another.
Code:
alias parse.ips {
  .fopen ips a.txt
  while !$feof { if $fread(ips) { inc -u %ips. $+ $v1 } }
  .fclose ips
  var %i = 1
  while $var(%ips.*,%i).value {
    if $v1 > 1 { echo -a Clones: $gettok($var(%ips.*,%i),-4-,46) ( $+ $v1 $+ ) }
    inc %i
  }
}

#93253 08/08/04 03:26 AM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
/me tests
Edit
Dude you rucking fock thanks

Last edited by Armada; 08/08/04 03:29 AM.
#93254 08/08/04 03:41 AM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
Hmm how would I through an else into there so if there isnt any clones woudl spit that out

#93255 08/08/04 03:47 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Code:
alias parse.ips {
  .fopen ips a.txt
  while !$feof { if $fread(ips) { inc -u %ips. $+ $v1 } }
  .fclose ips
  var %i = 1[color:blue],%r[/color]
  while $var(%ips.*,%i).value {
    if $v1 > 1 { echo -a Clones: $gettok($var(%ips.*,%i),-4-,46) ( $+ $v1 $+ ) [color:blue]| inc %r[/color] }
    inc %i
  }
[color:blue]  if !%r { echo -a Clones: (none) }[/color]
}

#93256 08/08/04 03:49 AM
Joined: Mar 2004
Posts: 540
A
Armada Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Mar 2004
Posts: 540
Ah thank you kindly

#93257 08/08/04 07:32 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

Iori's solution works great, however I wanted to show a different approach:
Code:
alias ipclones {
  window -h @@
  filter -fwtu 1 46 ips.txt @@
  var %a = 1, %b
  while $fline(@@,$line(@@,%a),0) {
    if $v1 > 1 { echo -a Clone: $line(@@,%a) ( $+ $v1 $+ ) | inc %b }
    inc %a $v1
  }
  if !%b { echo -a No clones found }
  window -c @@
}

Btw I don't necessarily have to use the u switch (numberic sort), but it has the nice effect that you will see the clones in ascending order of ip numbers.

Greets


Gone.

Link Copied to Clipboard