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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grabbing variables and comparing kerpm Shell Programming and Scripting 9 08-17-2008 05:45 PM
Grabbing result of sql command hern14 UNIX for Dummies Questions & Answers 3 07-23-2008 02:40 PM
Sed grabbing the last line of a file xgringo Shell Programming and Scripting 2 03-24-2008 09:24 PM
script grabbing cvs file ..... llsmr777 Shell Programming and Scripting 4 11-15-2007 03:16 PM
Grabbing lines out of a file based on a date bsp18974 Shell Programming and Scripting 2 07-17-2006 08:58 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 08-19-2008
hern14 hern14 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 22
Grabbing a value from an output file

I am executing a stored proc and sending the results in a log file. I then want to grab one result from the output parameters (bolded below, 2) so that I can store it in a variable which will then be called in another script. There are more details that get printed in the beginning of the log file, but what you see below gets printed at the end of the log file. This matters mentioning it because the line number where this value will show up in will not always be the same, due to possible errors that may occur in the program. I know that there is a grep -n command which tells you what line that value is, but seeing as this will be an automated script, I won't be able to see what line it is everytime the script runs. Any ideas/comments/suggestions?

Quote:
.............

db2 => CALL STORED_PROC('1-2',?,?,?,?)

Value of output parameters
--------------------------
Parameter Name : PROC_MSG
Parameter Value : STORED_PROC completed successfully

Parameter Name : BATCHES_UPDATED
Parameter Value : 2

Parameter Name : START_TS
Parameter Value : 2008-08-19-12.42.05.192288

Parameter Name : END_TS
Parameter Value : 2008-08-19-12.42.05.193165

Return Status = 0


db2 => disconnect current
DB20000I The SQL DISCONNECT command completed successfully.

db2 => quit
DB20000I The QUIT command completed successfully.
Thanks!
  #2 (permalink)  
Old 08-19-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Code:
#!/bin/sh
while read line
do
  if [ "$line" -eq "Parameter Name : BATCHES_UPDATED" ]
  then
    read line
    echo "$line" | awk '{ print $3 }'
    exit 0
  fi
done
(Untested)

Usage: scriptname.sh < output.file
  #3 (permalink)  
Old 08-19-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Or using awk alone:

Code:
awk '/Parameter Name : BATCHES_UPDATED/ { getline ; print $3 }' output.file
  #4 (permalink)  
Old 08-20-2008
hern14 hern14 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 22
Thanks!

Sweetness! Both work great! Thanks to you both!
Sponsored Links
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 12:05 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