Problem while execution of second set of commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem while execution of second set of commands
# 1  
Old 06-15-2008
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  
Old 06-15-2008
Remove the trailing & on the sql execution line. remove sleep as well.
# 3  
Old 06-15-2008
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  
Old 06-15-2008
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  
Old 06-15-2008
thanks

Franklin,
thanks my problem is solved
# 6  
Old 06-16-2008
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 02:09 PM..
# 7  
Old 06-16-2008
I have corrected the problem

thread can be closed

Last edited by ran16; 06-16-2008 at 03:35 PM.. Reason: problem solved
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl execution commands

I don't know to debug the program todaylive.pl program. plz someone let me know what are the commands I need to know to debug the perl programs to find out the error on it. (3 Replies)
Discussion started by: ramkumar15
3 Replies

2. Shell Programming and Scripting

Execution of Shell Commands

I have a question: Where would I put the Command line (of any command) so that it executes every time I log on? Where would I put it if I want it to execute every time I start a new shell? (5 Replies)
Discussion started by: Nabeel Nazir
5 Replies

3. Shell Programming and Scripting

Sequential execution of commands in ksh

I need to run few commands in a ksh script sequentially. Some of the commands are jobs submitted to the server and the consecutive commands are dependent on the completion of the jobs submitted to the server. It works if i separate the commands into different files like this #!/bin/ksh... (1 Reply)
Discussion started by: prashob123
1 Replies

4. Shell Programming and Scripting

Execution problem unix commands in Perl CGI

I am trying to run SSH , mkdir and other unix commands using Perl CGI. But i am not able to Execute these commands. Please help me out !!!! SSH and mkdir is necessity for me. I will be thankful to you...!!!!! I am trying like: In perl CGI file i am writing like: @list = `ssh... (28 Replies)
Discussion started by: Navrattan Bansa
28 Replies

5. Shell Programming and Scripting

Execution problem with repeat the same program with two set of same data

I got a program named as "fastq_to_fasta". I got a long list of file all named as AB1 and AB2. My input file is : 071022_L1_AB1.fq 012121_L1_AB1.fq 021213_L1_AB1.fq 012153_L1_AB1.fq 071022_L1_AB2.fq 012121_L1_AB2.fq 021213_L1_AB2.fq 012153_L1_AB2.fq . . . . . . My desired... (10 Replies)
Discussion started by: patrick87
10 Replies

6. UNIX for Advanced & Expert Users

multiple commands execution

Hi i have 3 sql scripts that need to be executed simultaneously, and independent of one another, how do i do that in Unix AIX 5.3 (1 Reply)
Discussion started by: yschd
1 Replies

7. Shell Programming and Scripting

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 then echo sysdate>test1 echo query1.txt>>test1 grep -i... (0 Replies)
Discussion started by: ran16
0 Replies

8. Shell Programming and Scripting

echo just 1 line before execution/set +-x

Suppose that you want to mostly not echo commands inside your script during execution (e.g. to not bog the user down with details that they do not care about) but that there is the occaisional script line that you would like to echo before you execute it. Is there an elegant way to achieve this?... (3 Replies)
Discussion started by: fabulous2
3 Replies

9. UNIX for Dummies Questions & Answers

Set User ID on execution mode.

I have a directory. To this directory, for Group bits combination, it is showing as 's'. Which I found out, it means "Set User ID on execution mode". Within this directory I am not able to create subfolder. Does it mean, only the Owner of this directory will be able to create subdirectories &... (5 Replies)
Discussion started by: videsh77
5 Replies

10. UNIX for Dummies Questions & Answers

Question on Set User ID on Execution

I want group to run one of my unix script as me . I when the script is run it should have my permission's not the group . I tried this : 1.Have a file called y.ksh cat y.ksh echo $LOGNAME >ak_test 2.Output file has this permission -rwx------ ak_test 3.Then I chnaged... (7 Replies)
Discussion started by: akrathi
7 Replies
Login or Register to Ask a Question

Featured Tech Videos