The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
read space filled file and replace text at specific position COD Shell Programming and Scripting 6 04-21-2008 05:40 AM
How to read a specific value from a Log file? cooolthud Shell Programming and Scripting 8 04-17-2008 11:30 AM
How to read specific lines in a bulk file using C file Programming rajan_ka1 High Level Programming 10 11-10-2005 03:29 AM
Shell Script to read specific lines in a file varshanswamy Shell Programming and Scripting 5 08-22-2005 07:12 PM
Delete specific lines in a text file dniz High Level Programming 9 08-08-2005 08:30 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-17-2006
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
read specific text from a log file

Hi guys

I need to retrieve the values in BOLD that I have mentioned in the below log file. I want to store those values in a variable, preferably the same name as the column name in the log file. if you paste the below mentioned log file in a notepad and remove the word wrap.. u will get a better idea.. thanks

Code:
Siebel Enterprise Applications Siebel Server Manager, Version 7.5.3.12 [16272] LANG_INDEPENDENT 
Copyright (c) 2001 Siebel Systems, Inc.  All rights reserved.

This software is the property of Siebel Systems, Inc., 2207 Bridgepointe Parkway,
San Mateo, CA 94404.

User agrees that any use of this software is governed by: (1) the applicable
user limitations and other terms and conditions of the license agreement which
has been entered into with Siebel Systems or its authorized distributors; and
(2) the proprietary and restricted rights notices included in this software.

WARNING: THIS COMPUTER PROGRAM IS PROTECTED BY U.S. AND INTERNATIONAL LAW.
UNAUTHORIZED REPRODUCTION, DISTRIBUTION OR USE OF THIS PROGRAM, OR ANY PORTION
OF IT, MAY RESULT IN SEVERE CIVIL AND CRIMINAL PENALTIES, AND WILL BE
PROSECUTED TO THE MAXIMUM EXTENT POSSIBLE UNDER THE LAW.

If you have received this software in error, please notify Siebel Systems
immediately at (650) 295-5000.

Type "help" for list of commands, "help <topic>" for detailed help

Connected to 1 server(s) out of a total of 1 server(s) in the enterprise

srvrmgr:sble01> list component 'eCustomerCMEObjMgr_enu'

SV_NAME  CC_ALIAS                CC_NAME                                              CT_ALIAS  CG_ALIAS        CC_RUNMODE CP_DISP_RUN_STATE  CP_NUM_RUN_   CP_MAX_TASK   CP_ACTV_MTS  CP_MAX_MTS_  CP_START_TIME        CP_END_TIME  CP_STATUS  CC_INCARN_NO  CC_DESC_TEXT  
-------  ----------------------  ---------------------------------------------------  --------  --------------  -----------  -----------------  -----------  -----------  -----------  -----------  -------------------  -----------  ---------  ------------  ------------  
sble01   eCustomerCMEObjMgr_enu  eCustomer Power Communications Object Manager (ENU)            Communications  Interactive  Running            4             20            1            1            2006-10-16 12:27:03                                                      

1 row returned.

srvrmgr:sble01>
  #2 (permalink)  
Old 10-17-2006
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
i need to write a script that will retrieve those values in bold only in my previous post. pls help me. thanks
  #3 (permalink)  
Old 10-17-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
sed -n "/CP_NUM_RUN_/,/rows* returned./p" file |
awk -v var1="CP_NUM_RUN_" -v var2="CP_MAX_TASK" '
$0 ~ var1 { 
flag=1
ind1=index($0,var1);ind2=index($0,var2);
for(i=1;i<=NF;++i)
{
        if( $i == var1 ) fld1=i;
        if( $i == var2 ) fld2=i;
}
getline
len1=length($fld1)
len2=length($fld2)
getline
}
flag == 1 {
print var1 ": " substr($0,ind1,len1) "\n" var2 ": " substr($0,ind2,len2)
}'
Above code will work only if the value of field aligns with "--------------"
  #4 (permalink)  
Old 10-17-2006
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
thanks anbu.. i will implement this.. and will let you know.
  #5 (permalink)  
Old 10-17-2006
ragha81 ragha81 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 145
hi anbu,

i implemented your code. i just did a small change. i changed 'awk' to 'nawk' because its solaris OS. I didnt get the output when i used 'awk'.

the output of my code is as follows
Code:
CP_NUM_RUN_: 3
CP_MAX_TASK: 20
CP_NUM_RUN_:
CP_MAX_TASK:
CP_NUM_RUN_:
CP_MAX_TASK:
I want my output to be like this
Code:
CP_NUM_RUN_: 3
CP_MAX_TASK: 20
I did a set -x and i got the following

Code:
+ nawk -v var1=CP_NUM_RUN_ -v var2=CP_MAX_TASK
$0 ~ var1 {
flag=1
ind1=index($0,var1);ind2=index($0,var2);
for(i=1;i<=NF;++i)
{
        if( $i == var1 ) fld1=i;
        if( $i == var2 ) fld2=i;
}
getline
len1=length($fld1)
len2=length($fld2)
getline
}
flag == 1 {
print var1 ": " substr($0,ind1,len1) "\n" var2 ": " substr($0,ind2,len2)
}
CP_NUM_RUN_: 3
CP_MAX_TASK: 20
CP_NUM_RUN_:
CP_MAX_TASK:
CP_NUM_RUN_:
CP_MAX_TASK:
+ exit
I appreciate your help very much. pls help me with it.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0