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-30-2010, 02:01 PM
Tony Schreiner
 
Default how to separate individual logs?

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

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 04:19 AM
hadi motamedi
 
Default how to separate individual logs?

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

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

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



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 09:02 AM
hadi motamedi
 
Default how to separate individual logs?

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 "
" | 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.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 09:06 AM
hadi motamedi
 
Default how to separate individual logs?

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'
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 04:14 PM
John Doe
 
Default how to separate individual logs?

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 "
" | 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



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-01-2010, 04:52 PM
Les Mikesell
 
Default how to separate individual logs?

On 12/1/2010 11:14 AM, John Doe wrote:
> 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 "
" | 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.

--
Les Mikesell
lesmikesell@gmail.com
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 12-03-2010, 09:50 AM
John Doe
 
Default how to separate individual logs?

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



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

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'
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 11:59 AM.

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