Sponsored Content
Top Forums Shell Programming and Scripting Help with gawk script that aggregates ip address ranges Post 302333762 by gustisok on Tuesday 14th of July 2009 03:48:19 AM
Old 07-14-2009
Howdy Ygor and summer_cherry Smilie

Thanks for trying to help! Smilie


Okie, lets see now:

When I tried Ygor's script:
Code:
gawk -f test.awk cbl-block-list.txt > cbl-block-list.p2p

After a few minutes my puter froze and bam... this error popped up.

Code:
gawk: test.awk:5: (FILENAME=cbl-block-list.txt FNR=3102944) fatal: format_tree:
obuf: can't allocate memory (Not enough space)

I believe I didn't mention the hardware specs of my PC and the OS:
3GB (thats 2x1GB and 2x512MB, not 4 GB on a 32bit OS), 2x dual core Intel proc (that's dual proc mobo), 4 HDDs of which two are in mirror and two are striped for better filesystem performance.

I still believe the prog should've had enough free mem to perform... but as I mentioned before - the file I need to run aggregation on is around 300-400MB in size (after being converted from initial 100-150MB of pure unique IPs) - that's not a small chunk =) - so it might have attempted a huge allocation of memory as it worked its way through array creations?
If you want, I can provide you the file via some file-exchange service so you can test it on or something?

The OS is WinXP 32bit since that's where protowall is located, but scripts are all running via unxutils.

I tried running the script on a 6MB file containing just IP addresses:
Code:
gawk -f test.awk small-chunk.txt > small-chunk.p2p
gawk: test.awk:9: (FILENAME=small-chunk.txt FNR=443897) fatal: function `asorti'
 not defined

Will take a peek and see whats with the asorti function.


When I tried to run summer_cherry's script:
Code:
 
gawk -f test2.awk cbl-block-list.txt > cbl-block-list.p2p
gawk: test2.awk:3: while(<DATA>){
gawk: test2.awk:3: ^ parse error
gawk: test2.awk:3: while(<DATA>){
gawk: test2.awk:3:              ^ parse error
gawk: test2.awk:5:      my @tmp=split("[.]",$_);
gawk: test2.awk:5:         ^ invalid char '@' in expression

Oopsie... did I just do that? Smilie Guess my gawk doesn't like it Smilie Perhaps my perl would like it better?

I am running gawk via unxtools and not on a native unix so environment, so that might be a slight problem in some cases.

Lets see if we (well - you is more correct Smilie) can make these scripts work. Har Har Smilie
I still gotta properly figure out the fine magic behind those lines.

And again - thanks a bunch for helping me work this one out!

Cheers,

Matt

PS. My appologies on broken English .)

Last edited by gustisok; 07-14-2009 at 04:56 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to use variables and gawk in a script?

Hi, I want to define variables in a shell script and make gawk use them to make some operations Mfn = $(grep " 1 " $fitxer | gawk '{print $2}') Xfn = $(grep " 1 " $fitxer | gawk '{print $3}') Yfn = $(grep " 1 " $fitxer | gawk '{print $4}') Zfn = $(grep " 1 " $fitxer | gawk... (9 Replies)
Discussion started by: pau
9 Replies

2. UNIX for Dummies Questions & Answers

Calculating field using AWK, or GAWK script

Hello all, I'm totally new to UNIX/Linux but I'm taking a course in it at my local JC. My question: I have been tasked with writing a gawk script that will create a nicely formatted report. That part I've done ok on...however, the very last thing that must be done is a calculation of a... (4 Replies)
Discussion started by: Trellot
4 Replies

3. Shell Programming and Scripting

gawk script

Hey guys need your help with an gawk script... here's what I have so far gawk '^d/ {printf "%-20s %-10s %-10s %-10s %-4s%2s %5s\n",$9,$1,$3,$4,$6,$7,$8}' ls.kbr The file ls.kbr is a capture of 'ls-al' What I want gawk to do is: 1) Find only directories (this is working) 2) skip lines... (2 Replies)
Discussion started by: zoo591
2 Replies

4. Shell Programming and Scripting

Issues with filtering duplicate records using gawk script

Hi All, I have huge trade file with milions of trades.I need to remove duplicate records (e.g I have following records) 30/10/2009,trdeId1,..,.. 26/10/2009.tradeId1,..,..,, 30/10/2009,tradeId2,.. In the above case i need to filter duplicate recods and I should get following output.... (2 Replies)
Discussion started by: nmumbarkar
2 Replies

5. Programming

need help with gawk script

hi i've already created this script. When I execute the script it takes the argument and compares it to the 3rd column of the script. What I was wondering if I could get some help with is. I want to add another column to the script and it will be the result of a set number for example, (2000 - 3rd... (3 Replies)
Discussion started by: gengar
3 Replies

6. Windows & DOS: Issues & Discussions

Gawk Script in Windows batch file - Help

Good morning all. I have been running into a problem running a simple gawk script that selects every third line from an input file and writes it to an output file. gawk "NR%3==0" FileIn > FileOut I am attempting to run this command from a batch file at the command line. I have several hundred... (6 Replies)
Discussion started by: 10000springs
6 Replies

7. Shell Programming and Scripting

Help with gawk array, loop in tcsh script

Hi, I'm trying to break a large csv file into smaller files and use unique values for the file names. The shell script i'm using is tcsh and i'm after a gawk one-liner to get the desired outcome. To keep things simple I have the following example with the desired output. fruitlist.csv apples... (6 Replies)
Discussion started by: theflamingmoe
6 Replies

8. Shell Programming and Scripting

Search IP Address in list of ranges -- not working great

I have been struggling with a script to automate some security related activities. I have it pretty much working, all except the search. I have an input file formatted as such: 216.234.246.158 216.234.246.158 `` 24.249.221.22 24.249.221.200 `` 24.249.226.0 ... (4 Replies)
Discussion started by: tsunami4u
4 Replies

9. Shell Programming and Scripting

[BASH] Gawk + MYSQL script

Hello! I've got script to write. It should read databases (names, volumes) from table testdatabase and compares it to actually existing databases in /var/lib/mysql/. If there is no informations about database in table - we should see information "There is no declared informations about database... (1 Reply)
Discussion started by: Zimny
1 Replies

10. Shell Programming and Scripting

Gawk program not working in a script

I've written a very simple gawk program which runs when I execute it at the POSIX shell but the corresponding '.awk' script I wrote doesn't return any data. I'm on an HP-UX running gawk version 3.1. (w/all the defaults) (As you can probably guess I'm a newbie going through the manual and trying... (2 Replies)
Discussion started by: RUCerius
2 Replies
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy