FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 11-29-2010, 10:20 AM
John Doe
 
Default 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
 
Old 11-29-2010, 11:06 AM
"Raj kumar"
 
Default how to separate individual logs?

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

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 11-30-2010, 03:52 AM
hadi motamedi
 
Default 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
 
Old 11-30-2010, 07:09 AM
cybernet
 
Default how to separate individual logs?

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












_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 11-30-2010, 07:16 AM
hadi motamedi
 
Default 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
 
Old 11-30-2010, 07:24 AM
cybernet
 
Default how to separate individual logs?

> 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












_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 11-30-2010, 08:07 AM
hadi motamedi
 
Default how to separate individual logs?

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.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 11-30-2010, 08:58 AM
John Doe
 
Default how to separate individual logs?

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 '
' chars lurking around...
Forgot I did removed them manualy when I saw them...

cat Edit3 | tr -d "
" | 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



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 11-30-2010, 10:52 AM
hadi motamedi
 
Default how to separate individual logs?

On 11/30/10, John Doe <jdmls@yahoo.com> wrote:
> The trick is that your original file has '
' chars lurking around...
> Forgot I did removed them manualy when I saw them...
>
> cat Edit3 | tr -d "
" | 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?
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 11-30-2010, 12:09 PM
John Doe
 
Default how to separate individual logs?

From: hadi motamedi <motamedi24@gmail.com>

> On 11/30/10, John Doe <jdmls@yahoo.com> wrote:
> > The trick is that your original file has '
' chars lurking around...
> > Forgot I did removed them manualy when I saw them...
> > cat Edit3 | tr -d "
" | 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



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 07:25 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org