|
|
|||||||
My code is supposed to examine a proxy log line by line and is supposed to pull an element out of that line if it has the first two octets of a certain network in it and then write that IP to a temp array. It's only supposed to add the IP address if the IP has NOT already been previously added. The logic expressed in the last line was attempted below: Code: If AScan($ipAddresses,$arrLine[2]) = -1 ...for some reason, the array is keeping all entries of all of the IP addresses and I'm only trying to keep one, unique entry. Is there anything obvious that I'm doing wrong? Sample Output: 192.168.161.125 192.168.161.92 192.168.163.74 192.168.161.125 192.168.161.92 192.168.163.74 192.168.161.125 192.168.161.92 192.168.163.74 192.168.161.125 192.168.161.92 192.168.163.74 192.168.161.125 192.168.161.92 192.168.183.24 |
||||||||
|
|
|||||||
AScan() by default only does an exact match, not a partial. If you want a partial match on just the first two octets, you need the latest version of KiX and more parms. From the 4.52b beta liner notes: Quote: |
||||||||
|
|
|||||||
bah crap... thanx Les. I can use SubStr though with the current stable release to get what I'm looking for right? well it's going to have to cuz that's what i'm going to try. =P |
||||||||
|
|
|||||||
bah... nm Les. I confused myself thinking I was doing a partial match but I'm not. Here's more of the code so you can see actually waht's going on: Code: If $OpenRawFile = 0 AND $OpenReorgFile = 0 ...see, i'm trying to just make sure that the array element follows my ip address scheme and if it does, then i check to see if the WHOLE IP address already exists in the array. It always add the duplicated IPs into my temp array though.. =/ |
||||||||
|
|
|||||||
Hmm... found something even more weird now, when I print out @ERROR and my array element, they show up correct in the conditional but seem to still be writing bad information to the document... i don't get it... Code:
|
||||||||
|
|
|||||||
I don't think your problem is with AScan(). You keep iterating through a Do While loop and on every iteration of the loop, you also loop through your $ipaddresses array and write out the ENTIRE array. |
||||||||
|
|
|||||||
right and that's what i'm trying to do... ok here's my logic Les and tell me if i'm totally jacked up or not: as I scan each line of the proxy file, if the line has '192.168' in it, it allows further processing. That line is then split into elements of an array seperated by a space character. For every third element, it's supposed to scan my temp array ($ipAddresses) and if that value DOESN'T already exist in the array, it adds that new element to the array. (So at this point, I should have a temp of array of only the unique ip addresses, right?) Then I just write out all elements of that array into my text file... Is that not how you see the logic of my script? |
||||||||
|
|
|||||||
Quote: Wrong! You write out the array on EVERY iteration of your Do While loop. Move your For Each loop out of the Do While loop. |
||||||||
|
|
|||||||
First off, I'd like to thank you because that fixed my problem; it's always the freakin simplest logic problems i miss... =/ Thanx again for showing me the error of my ways Les. =D |