LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-08-2010, 11:36 AM   #16
Phier
Member
 
Registered: Nov 2009
Posts: 31

Original Poster
Rep: Reputation: 0

The new IP2 gets it's Country from the first IP2 instance that was looked up.

I'm not sure how to do it with sed 'cause sed outputs the whole file's contents each time it's called. So running sed for each newly found country outputs the file multiple times. That's why i've opted for processing each line at a time like in the above code.
 
Old 05-09-2010, 12:13 AM   #17
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
So i have one more question, does this script only update this file?
ie. does it do other things as well or not?
 
Old 05-09-2010, 02:19 AM   #18
Phier
Member
 
Registered: Nov 2009
Posts: 31

Original Poster
Rep: Reputation: 0
It moves and rsyncs a number of other files, but the files interaction we've been concerned with go like this:

Every 5 minutes:

Code:
rsync cvsfile,etc for stats
for each sqlfile
   sed sqlfile >> cvsfile
for each line of cvsfile
   jwhoisUpdate cvsfile > newcvsfile
mv newcvsfile cvsfile
rsync-and-remove sqlfiles
Whilst another database sql dump script periodically creates the sqlfiles with updates.

Cheers.
 
Old 05-09-2010, 04:37 AM   #19
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
hmm ... well looking at that it may almost pay to do your for loop actions all in awk.
What i mean is that you could have awk do the work and then call jwhois only for the lines that are necessary.

So are these line:
Quote:
2010-04-30 11:05:10,ICMP Echo Reply,Possible harmful network activity detected,3,<IP address>
Coming from the sql files?
Essentially i was thinking along the lines of:
Code:
awk -F, 'NF==5{<do jwhois>}' cvsfile >newcvsfile
This would then only perform the changes on the required lines.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simultaneous writes into different elements of an array estratos Programming 7 12-15-2006 06:36 AM
Passing Array Elements to functions melikai Programming 4 10-31-2006 10:27 PM
Renaming array elements in bash bryan.out.there Programming 2 05-31-2006 11:44 PM
odd behaviour of array elements in c++ markhod Programming 4 03-14-2005 09:58 AM
perl - get number of elements in an array AM1SHFURN1TURE Programming 3 03-07-2005 03:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration