The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What is wrong with the rsh? opensuse Shell Programming and Scripting 2 10-19-2008 11:51 AM
What's wrong with this sed command? delete & append minifish Shell Programming and Scripting 5 04-08-2008 10:34 PM
Whats wrong with the mv command dsravan Shell Programming and Scripting 0 08-10-2006 04:30 PM
What am I doing wrong guptan UNIX for Advanced & Expert Users 2 07-05-2005 11:32 AM
where have i gone wrong? Blip Shell Programming and Scripting 3 01-28-2004 04:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-13-2009
akhtar.bhat akhtar.bhat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 19
Arrow Is anything wrong with this command

Hi All,

can anyone tell me what is wrong with this command.

tail -f /opt/olr-logs/PaymentGateway.log | grep "DEBUG - Start! AkhtarPaymentGateway - generateChecksum" | awk '{print $13}' | sed 's/,//g'>> abc


But I found nothing in the file abc

Please do help me.or Provide me some altenative way for this command.

Thanks and regards,
Akhtar Bhat.
  #2 (permalink)  
Old 02-13-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,285
Use each command one after another....
1st only the tail -f. If it works add the pipe with the grep. If it works, add the awk and so on.
  #3 (permalink)  
Old 02-13-2009
akhtar.bhat akhtar.bhat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 19
Arrow Script to monitor IP's

Dear zaxxon,

Basically I need a shell script to monitor different IP's in the live logs.

The problem is I am new to shell scripting and dont know much about the scripting.

Look at the below line, the pattern will be always like this:

[2009-02-13 15:34:53,768] DEBUG - Start! PaymentGatewayFactory - getPaymentGateway (2, 100.00,Mohit Aggarwal,1942, 1,123.50.162.248, , 9821934958)

I want to extract the different IP's from this line every time when this kind of line adds to the logs.

Once the IP's are extracted and moved to another file, I want to compare them with previously existing IP's instantly and if the count of any particular IP will be more than predefined Value that IP should be Displayed on the Screen.
Hope you got, what is the problem ?
Please do help me in this matter.....

Thanks and regards,
Akhtar Bhat.
  #4 (permalink)  
Old 02-13-2009
Whiteboard's Avatar
Whiteboard Whiteboard is offline
Registered User
  
 

Join Date: Feb 2009
Location: @........
Posts: 111
Use the below cmd for getting the ip(Assuming the format you have given)....

Quote:
tail -f /opt/olr-logs/PaymentGateway.log | grep "DEBUG - Start! PaymentGatewayFactory - getPaymentGateway" | awk -F "," '{print $7}'
  #5 (permalink)  
Old 02-13-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Quote:
Originally Posted by Whiteboard View Post
Use the below cmd for getting the ip(Assuming the format you have given)....
Code:
tail -f /opt/olr-logs/PaymentGateway.log | grep "DEBUG - Start! PaymentGatewayFactory - getPaymentGateway" | awk -F "," '{print $7}'
No need for 'grep' when piped into 'awk'.
  #6 (permalink)  
Old 02-13-2009
akhtar.bhat akhtar.bhat is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 19
Thanks for your valuable time,
But the solution shown below is not working properly although the same command is working when I replace the tail -f with the less command.

tail -f /opt/olr-logs/PaymentGateway.log | grep "DEBUG - Start!
PaymentGatewayFactory - getPaymentGateway" | awk -F "," '{print $7}'
  #7 (permalink)  
Old 02-13-2009
Ankgne Ankgne is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 12
Hi Akhtar ,

Try this command
grep "DEBUG - Start! PaymentGatewayFactory - getPaymentGateway" test.txt|cut -d"(" -f2|awk -F, '{print $6}'>>xyz.txt

The above command will write the ip address to the flat file .xyz.txt. But this will only work fine if you are sure that ip address will be the 6th field of this substring (2, 100.00,Mohit Aggarwal,1942, 1,123.50.162.248, , 9821934958).
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0