Is anything wrong with this command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Is anything wrong with this command
# 1  
Old 02-13-2009
CPU & Memory 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  
Old 02-13-2009
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  
Old 02-13-2009
CPU & Memory 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  
Old 02-13-2009
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  
Old 02-13-2009
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).
# 6  
Old 02-13-2009
Quote:
Originally Posted by Ankgne
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).
No necessary for cut command here.... change your awk portion code to print 7th column with , as delimiter(To make ur code as simple as possibleSmilie)
# 7  
Old 02-13-2009
Quote:
Originally Posted by Whiteboard
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'.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What is wrong with my awk command?

The below code usually works when the value for the COLUMN variable is numerical. but im in a situation where the number of fields in a file is not definitive. it changes. but what is static is that the value i want to retrieve from the log is 3 fields from the last field. which is what i... (9 Replies)
Discussion started by: SkySmart
9 Replies

2. Shell Programming and Scripting

What's wrong with the following command?

Hi all, I'm trying to run the following command to get all files in one directory to another with the files' timestamps preserved, cp -p /logs/dvgbiau/batch/* /logs/dvgbiau/tmp_batch Note that ./batch and ./tmp_batch are two sub-directories under /logs/dvgbiau. The error was,... (1 Reply)
Discussion started by: isaacniu
1 Replies

3. Solaris

Last command displays wrong information

Hi am having Solaris10 - Sun-Fire-V890 server, the information displayed by Last command is wrong how do i get this sorted without loosing any datas.. # uptime 12:32am up 20 day(s), 33 min(s), 1 user, load average: 1.54, 1.82, 1.93 # last reboot reboot system boot Sat... (9 Replies)
Discussion started by: Sojourner
9 Replies

4. AIX

Command last displays wrong hostname

I faced an interesting problem on my AIX servers. When I checked last logins with command last I saw that hostnames are wrong. Let say, I made login from workstation xxxxx and with the command last I saw: root pts/2 yyyyy 5 jan 15:38 still logged in Ping xxxxx and ping... (3 Replies)
Discussion started by: giovanni
3 Replies

5. Shell Programming and Scripting

Wrong output in find command

Hi guys - I am trying a small script to tell me if there is a file that exists less than 1k. It should report ERROR, otherwise the check is good. I wrote this script down, however it never runs in the if/then statement. It always returns the echo ERROR. MYSIZE=$(find /home/student/dir1... (8 Replies)
Discussion started by: DallasT
8 Replies

6. Emergency UNIX and Linux Support

getting wrong output with AWK command!!!

i have a file which gets appended with 9 records daily and the file keeps growing from then...i use to store the previous day files count in a variable called oldfilecount and current files count as newfilecount.my requirement is that i need to start processing only the new records from the... (3 Replies)
Discussion started by: ganesh_248
3 Replies

7. UNIX for Dummies Questions & Answers

what is wrong with this command?

Hello, I try to using the below command to find out all the datafiles under "sja" direcotory. $ xargs -i find {} -type f -ls < sja /bin/ksh: sja: cannot open so can you tell me what is wrong? Thanks Jerry (3 Replies)
Discussion started by: GreatJerry
3 Replies

8. UNIX for Advanced & Expert Users

what is wrong with this find command

i am trying to find the files which are more than 100MB and it was created 10 days ago. find /lola/loaded -size +102400 -mtime -10 -print | xargs ls -ltr -rw-rw-r-- 1 lola_adm gdrmp 82054170 Jun 23 06:17 /lola/loaded/ILMEMBER20090622.txt -rw-rw-r-- 1 lola_adm gdrmp 652080494 Jun 24... (3 Replies)
Discussion started by: sudhiroracle
3 Replies

9. Shell Programming and Scripting

tr command giving wrong output

Hi All, i have a file which have many fields delimited by ,(comma) now i have to show only few fields and not all. the sample text file looks like this: TYPE=SERVICEEVENT, TIMESTAMP=05/06/2009 11:01:40 PM, HOST=sppwa634, APPLICATION=ASComp, FUNCTION=LimitsService, SOU... (8 Replies)
Discussion started by: usha rao
8 Replies

10. Shell Programming and Scripting

Whats wrong with the mv command

I am sorry guys I have figured out the error myself. (0 Replies)
Discussion started by: dsravan
0 Replies
Login or Register to Ask a Question