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
problem with shell script execution anju Shell Programming and Scripting 2 05-08-2008 01:50 AM
Remote commands problem using RSH & Rexec fhuwaidy UNIX for Advanced & Expert Users 0 01-15-2008 04:22 PM
use two unix commands to solve the following problem vicky20000 UNIX for Advanced & Expert Users 3 01-20-2007 06:35 PM
problem with directory commands tej.buch Shell Programming and Scripting 1 01-23-2006 02:22 AM
Find & tar execution problem ianf Shell Programming and Scripting 3 05-24-2002 09:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-15-2008
ran16 ran16 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 16
Problem while execution of second set of commands

Hi,
I have a shell script with code
. perf.env
cd $QRY_DIR
for SHELL_FILE in sql1
do
export SNAME=$SHELL_FILE
${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} &
RC=$(expr ${RC:-0} + $? )
sleep 60
if [ $RC == 0 ]
then
echo sysdate>test1
echo query1.txt>>test1
grep -i selected sql_test.txt>>test1
grep -i elapsed sql_test.txt>>test1
awk '/rows selected/ { $0=$1 } /Elapsed/ { split($2, t, ":");$0=3600*t[0]+60*t[1
]+'t[2]+.001*t[3]' }{ out=out sprintf("%s%s",NR==1?"":",","\047"$0"\047") }END{
print("insert into FDW_QUERY_TIME values ("out");") }' test1>test2
fi
done
exit $RC

My problem is after executing the sql1 and the spooling is completed I want to execute the next bit of code after sleep.I actually want to grep the spooled file items.but before spooling is completed the command are executed.
Can any one help me to correct this
  #2 (permalink)  
Old 06-15-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Remove the trailing & on the sql execution line. remove sleep as well.
  #3 (permalink)  
Old 06-15-2008
ran16 ran16 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 16
It worked but still one doubt

Jim,
it worked.But I have one more doubt
My Elapsed time is Elapsed: 00:00:26.42
So in seconds i should get 26.042 second.but as per this code I am getting
it as 0.02642.
Can you please tell me where I have made a mistake.

Thanks
  #4 (permalink)  
Old 06-15-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,294
Code:
$0=3600*t[0]+60*t[1]+'t[2]+.001*t[3]
The first piece of the array is stored in t[1] not in t[0].

Regards
  #5 (permalink)  
Old 06-15-2008
ran16 ran16 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 16
thanks

Franklin,
thanks my problem is solved
  #6 (permalink)  
Old 06-16-2008
ran16 ran16 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 16
one more problem in the same code

I have further a problem with my code.
. perf.env
cd $QRY_DIR
for SHELL_FILE in sql1 sql2
do
export SNAME=$SHELL_FILE
${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME}
RC=$(expr ${RC:-0} + $? )

if [ $RC == 0 ]
then
sel1='/selected/{p;q;}'
sel2='/Elapsed/{p;q;}'
for i in *.txt
do
TZ=`date +%Z` ; a=`date +%d-%b-%y`
echo $a >$i_1
echo 1 >>$i_1
sed -n $sel1 $i >>$i_1
sed -n $sel2 $i >>$i_1

awk '/rows selected/ { $0=$1 } /Elapsed/ { split($2, t, ":");$0=3600*t[1]+60*t[2]+t[3] }{ out=out sprintf("%s%s",NR==1?"":",","\047"$0"\047") }END{ print(""out"") }' $i_1>$i_1_r
done
fi
done
exit $RC

I am getting error
unknown echo command....
and also while printing the out I do not want single quotes but need the fields seperated by commas only.
And also I want to sqlldr user/pwd control=f1.ctl data=$i_1_r (i.e I want the $i_1_r files to be loaded to database)

Please help me ..

Last edited by ran16; 06-16-2008 at 12:09 PM..
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 10:46 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