Dear All I have captured a file in my centos showing logs captured from many modules concurrently. Please find attached a sample of the file. As you see, there are logs from individual modules that have been captured concurrently. For example, there are logs from IPTR,SNMP,HLR,TCAP,XAPP,and SCCP modules but they are coming concurrently.Each log has the header name of its accompanied module in the beginning. I need to have the log of each modules separately. Can you please show me the power of centos on how to separate individual module's logs from the whole? Thank you
On Mon, Nov 29, 2010 at 2:58 PM, hadi motamedi motamedi24@gmail.com wrote:
Dear All I have captured a file in my centos showing logs captured from many modules concurrently. Please find attached a sample of the file. As you see, there are logs from individual modules that have been captured concurrently. For example, there are logs from IPTR,SNMP,HLR,TCAP,XAPP,and SCCP modules but they are coming concurrently.Each log has the header name of its accompanied module in the beginning. I need to have the log of each modules separately. Can you please show me the power of centos on how to separate individual module's logs from the whole?
What program do you use for it? Wireshark? I don't think the OS would care?
From: hadi motamedi motamedi24@gmail.com
I have captured a file in my centos showing logs captured from many modules concurrently. Please find attached a sample of the file. As you see, there are logs from individual modules that have been captured concurrently. For example, there are logs from IPTR,SNMP,HLR,TCAP,XAPP,and SCCP modules but they are coming concurrently.Each log has the header name of its accompanied module in the beginning. I need to have the log of each modules separately. Can you please show me the power of centos on how to separate individual module's logs from the whole?
Here is "The Power of CentOS"!!! (in approximately 3 minutes...)
cat edit.txt | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done
JD
PS: I wonder if I am doing your school homework...
Please unsubscribe the side on my email
-----Original Message----- From: centos-bounces@centos.org [mailto:centos-bounces@centos.org] On Behalf Of John Doe Sent: 29 November 2010 16:50 To: CentOS mailing list Subject: Re: [CentOS] how to separate individual logs?
From: hadi motamedi motamedi24@gmail.com
I have captured a file in my centos showing logs captured from many modules concurrently. Please find attached a sample of the file. As you see, there are logs from individual modules that have been captured concurrently. For example, there are logs from IPTR,SNMP,HLR,TCAP,XAPP,and SCCP modules but they are coming concurrently.Each log has the header name of its accompanied module in the beginning. I need to have the log of each modules separately. Can you please show me the power of centos on how to separate individual module's logs from the whole?
Here is "The Power of CentOS"!!! (in approximately 3 minutes...)
cat edit.txt | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done
JD
PS: I wonder if I am doing your school homework...
_______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On 11/29/10, John Doe jdmls@yahoo.com wrote:
Here is "The Power of CentOS"!!! (in approximately 3 minutes...)
cat edit.txt | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done
JD
Thank you very much for your help. I tried for your code but I am receiving the following error: -bash:[1:command not found -bash:$LOGFILE:ambiguous redirect Can you please correct me?
can you please tell what that command does ?:))
________________________________ From: hadi motamedi motamedi24@gmail.com To: CentOS mailing list centos@centos.org Sent: Tue, November 30, 2010 6:52:30 AM Subject: Re: [CentOS] how to separate individual logs?
On 11/29/10, John Doe jdmls@yahoo.com wrote:
Here is "The Power of CentOS"!!! (in approximately 3 minutes...)
cat edit.txt | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done
JD
Thank you very much for your help. I tried for your code but I am receiving the following error: -bash:[1:command not found -bash:$LOGFILE:ambiguous redirect Can you please correct me? _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On 11/30/10, cybernet cybernet2u@yahoo.com wrote:
can you please tell what that command does ?:))
Sorry. Which command do you mean?
cat edit.txt | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done
________________________________ From: hadi motamedi motamedi24@gmail.com To: CentOS mailing list centos@centos.org Sent: Tue, November 30, 2010 10:16:43 AM Subject: Re: [CentOS] how to separate individual logs?
On 11/30/10, cybernet cybernet2u@yahoo.com wrote:
can you please tell what that command does ?:))
Sorry. Which command do you mean? _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On 11/30/10, cybernet cybernet2u@yahoo.com wrote:
cat edit.txt | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done
As you see in the original text file, each module's log is started with the module's name following with '>..' characters so the code is expected to search for the start of each module's log and try to separate its specific log. I tried for the code but it seems that it has some syntax error that needs to be corrected.
On Nov 30, 2010, at 4:07 AM, hadi motamedi wrote:
On 11/30/10, cybernet cybernet2u@yahoo.com wrote:
cat edit.txt | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done
As you see in the original text file, each module's log is started with the module's name following with '>..' characters so the code is expected to search for the start of each module's log and try to separate its specific log. I tried for the code but it seems that it has some syntax error that needs to be corrected. _______________________________________________
That error would happen if you did not have a space between [ and $?
Tony Schreiner
On 11/30/10, Tony Schreiner tony.schreiner@bc.edu wrote:
That error would happen if you did not have a space between [ and $?
Tony Schreiner
Thank you very much for your help. Actually, I didn't have got a clear understanding of your code. Sorry for my mis-understanding. At now, I analyzed the code and totally understand it. I corrected my mistake in typing the command but still receiving the following error: '-bash: $LOGFILE: ambiguous redirect' Can you please do me favor and correct me on my mistake? Please be informed that I am using centos 5.2
From: hadi motamedi motamedi24@gmail.com
On 11/29/10, John Doe jdmls@yahoo.com wrote:
cat edit.txt | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done
Thank you very much for your help. I tried for your code but I am receiving the following error: -bash:[1:command not found -bash:$LOGFILE:ambiguous redirect Can you please correct me?
The trick is that your original file has '\r' chars lurking around... Forgot I did removed them manualy when I saw them...
cat Edit3 | tr -d "\r" | while read LINE; do
Instead of just copy/pasting, try to understand what it does. Here is how it works: - Read each line in the LINE variable. - If the line contains the string '>..', it is a "section" line. Set the log filename to the section title. - If not, just write the line to the current log filename.
JD
On 11/30/10, John Doe jdmls@yahoo.com wrote:
The trick is that your original file has '\r' chars lurking around... Forgot I did removed them manualy when I saw them...
cat Edit3 | tr -d "\r" | while read LINE; do
Instead of just copy/pasting, try to understand what it does. Here is how it works:
- Read each line in the LINE variable.
- If the line contains the string '>..', it is a "section" line. Set the log filename to the section title.
- If not, just write the line to the current log filename.
JD
Sorry. I didn't get the point clearly. What I need is to separate the log files from each of the modules. For example, I need all of the log files coming from XAPP module. In the main log, it can be distinguished by searching for the following line: XAPP >.. Then you see subsequent lines that are logs coming from this module. Then the logs from another module will come following the previous one. I think you code is not doing this . Can you please correct me on my understanding of your code body?
From: hadi motamedi motamedi24@gmail.com
On 11/30/10, John Doe jdmls@yahoo.com wrote:
The trick is that your original file has '\r' chars lurking around... Forgot I did removed them manualy when I saw them... cat Edit3 | tr -d "\r" | while read LINE; do Instead of just copy/pasting, try to understand what it does. Here is how it works:
- Read each line in the LINE variable.
- If the line contains the string '>..', it is a "section" line. Set the log filename to the section title.
- If not, just write the line to the current log filename.
Sorry. I didn't get the point clearly. What I need is to separate the log files from each of the modules. For example, I need all of the log files coming from XAPP module. In the main log, it can be distinguished by searching for the following line: XAPP >.. Then you see subsequent lines that are logs coming from this module. Then the logs from another module will come following the previous one. I think you code is not doing this . Can you please correct me on my understanding of your code body?
My pseudo-code does exactly what you described (re-read it)...
And it creates <MODULE>.log files... $ ll -n total 36 -rw-r--r-- 1 2000 500 4678 nov 30 10:49 Edit3 -rw-r--r-- 1 2000 500 39 nov 30 10:54 HLR.log -rw-r--r-- 1 2000 500 2320 nov 30 10:54 IPTR.log -rw-r--r-- 1 2000 500 478 nov 30 10:54 SCCP.log -rw-r--r-- 1 2000 500 754 nov 30 10:54 SNMP.log -rw-r--r-- 1 2000 500 507 nov 30 10:54 TCAP.log -rw-r--r-- 1 2000 500 281 nov 30 10:54 XAPP.log -rwxr-xr-x 1 2000 500 207 nov 30 10:54 test.sh*
If you think it is not doing it, I cannot help you... Either ask your sysadmin to help you, or use someone else code...
JD
On 11/30/10, John Doe jdmls@yahoo.com wrote:
My pseudo-code does exactly what you described (re-read it)...
And it creates <MODULE>.log files... $ ll -n total 36 -rw-r--r-- 1 2000 500 4678 nov 30 10:49 Edit3 -rw-r--r-- 1 2000 500 39 nov 30 10:54 HLR.log -rw-r--r-- 1 2000 500 2320 nov 30 10:54 IPTR.log -rw-r--r-- 1 2000 500 478 nov 30 10:54 SCCP.log -rw-r--r-- 1 2000 500 754 nov 30 10:54 SNMP.log -rw-r--r-- 1 2000 500 507 nov 30 10:54 TCAP.log -rw-r--r-- 1 2000 500 281 nov 30 10:54 XAPP.log -rwxr-xr-x 1 2000 500 207 nov 30 10:54 test.sh*
If you think it is not doing it, I cannot help you... Either ask your sysadmin to help you, or use someone else code...
JD
Thank you very much for your technical support. I carefully read your code and analyzed it. At now , I can understand it. Sorry for my mis-understanding. I tried to run it but got error. I even tried to make it as an script file and made it executable but still getting the following error: 'syntax error near unexpected token 'done' 'done' I am using centos 5.2 It seems that something wrong my case. Can you please help me?
From: hadi motamedi motamedi24@gmail.com
I even tried to make it as an script file and made it executable but still getting the following error: 'syntax error near unexpected token 'done'
Ok, last try... Did you copy/pasted my code? Did you type it? Saying just that there's a syntax error without showing the code you used does not help...
JD
On 12/1/10, John Doe jdmls@yahoo.com wrote:
Ok, last try... Did you copy/pasted my code? Did you type it? Saying just that there's a syntax error without showing the code you used does not help...
JD
Please find below the code that I tried : cat Edit3 | tr -d "\r" | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done Please do me favor and correct me on my mistakes.
From: hadi motamedi motamedi24@gmail.com
On 12/1/10, John Doe jdmls@yahoo.com wrote:
Ok, last try... Did you copy/pasted my code? Did you type it? Saying just that there's a syntax error without showing the code you used does not help...
Please find below the code that I tried : cat Edit3 | tr -d "\r" | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE" >> $LOGFILE fi done Please do me favor and correct me on my mistakes.
I copy/pasted the code above and it works fine... If I indent it like mine, they are identical. Check that ftp does not add control chars. You run it with bash, right? Ask your sysadmin/colegue to help you.
JD
On 12/1/2010 11:14 AM, John Doe wrote:
From: hadi motamedimotamedi24@gmail.com
On 12/1/10, John Doejdmls@yahoo.com wrote:
Ok, last try... Did you copy/pasted my code? Did you type it? Saying just that there's a syntax error without showing the code you used does not help...
Please find below the code that I tried : cat Edit3 | tr -d "\r" | while read LINE; do echo "$LINE" | grep -q '>..' if [ $? -eq 0 ]; then LOGFILE=`echo $LINE | cut -d' ' -f1`.log else echo "$LINE">> $LOGFILE fi done Please do me favor and correct me on my mistakes.
I copy/pasted the code above and it works fine... If I indent it like mine, they are identical. Check that ftp does not add control chars. You run it with bash, right? Ask your sysadmin/colegue to help you.
If the first line of the input file used doesn't match the pattern you'd probably get an error in the redirect since $LOGFILE would not be set.
From: Les Mikesell lesmikesell@gmail.com
If the first line of the input file used doesn't match the pattern you'd probably get an error in the redirect since $LOGFILE would not be set.
If the data file does not respect the order section+body... he could just add a LOGFILE="garbage.txt" at the begining of the script...
JD
On 12/1/10, John Doe jdmls@yahoo.com wrote:
I copy/pasted the code above and it works fine... If I indent it like mine, they are identical. Check that ftp does not add control chars. You run it with bash, right? Ask your sysadmin/colegue to help you.
JD
Sorry to forget to mention that your code was really 'The Power of cents'
On 12/1/10, John Doe jdmls@yahoo.com wrote:
Ok, last try... Did you copy/pasted my code? Did you type it? Saying just that there's a syntax error without showing the code you used does not help...
JD
Sorry to forget to mention that I have copied your code from your message into a text file and then ftp it to my centos 5.2 server and make it executable by 'chmod +x'