Dear All
On my Linux server, I need to separate the individual logs coming from various modules concurrently. Please find below a sample of the logs:
' IPTR >..
Read Subscript: 153 Write Subscript: 154 Port: 4972
Current time: Tue Nov 23 15:33:53 2010
Sent packet to 172.18.99.1 4972 #0
packet is 1081 bytes long, contains:
30 82 04 35 02 01 01 04 06 70 75 62 6C 69 63 A7 82 04 26 02 01 01 02 01 FF 02 0107 30 82 04 19 30 82 04 15 06 0F 2B 06 01 04 01 8A 5D 01 03 03 04 02 07 AE 0B 0482 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 00 00 00 00 00 00 00 00 00 00 00 00
SNMP >..
local:4972 ==> 172.18.99.1:4972 Type=Trap-V2, RID=136337360, Error=255, Bind=1[37m
oid[0]=1.3.6.1.4.1.1373.1.3.3.4.2.7.5899, vartype=04, msglen=1024
local:4969 ==> 172.18.99.1:4969 Type=Trap-V2, RID=1, Error=80, Bind=1[37m
oid[0]=1.3.6.1.4.1.1373.1.3.3.8.2.7.779, vartype=04, msglen=1024
HLR >..
HLR recv <- DELIM ind
Dialogue id:1927'
As you see, each log begins with its modules name that I need to separate its individual log. So I have wrote the following code to separate it:
#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
But when I run it, I am receiving the following error:
-bash: -f1.log : command not found
-bash: $LOGFILE : ambiguous redirect
Can you please help me to correct my code?
Thank you
mark54g
December 4, 2010, 12:33am
2
>LOGFILE=`echo $LINE | cut -d' ' -f1`.log appears to be your problem. It is either quoting or escaping.
Play around with that.
Thank you very much for your reply. Sorry I didn't get the point clearly. Can you please give me more hints? How you will modify it if you write code like this?
how to create my own web sites.
Please don't inject your own questions in completely unrelated threads.