Sponsored Content
Top Forums Shell Programming and Scripting Differences in printed commands after execution with same code Post 302573992 by mjf on Wednesday 16th of November 2011 08:22:46 AM
Old 11-16-2011
I'm trying to find the reason for the different behavior when the commands and arguments are printed using set -x when the same function is executed. In the Undesired Results, you can see that when $status_cnt = 2, the end result is the same (i.e. the loop continues) as in the Desired Results but when when $status_cnt = 1, the loop prematurely exits in the Undesired Results.
The purpose of the translate function tr -d [0-9] is to delete numerics before assigning to temp variable but why do I see "+ + tr -d 2" in the Undesired Results and why is the print order different when executing the same function?


Here is the function:

Code:
 
check_report_completion()
#ARG1 = jobid array
{
set -x
jobid=$1
status_cnt=9999
until [ $status_cnt -eq 0 ]
do
sleep 15 
sqlplus -s $AS_CONNECT_STRING<<EOF |read status_cnt
whenever sqlerror exit sql.sqlcode; 
SET FEEDBACK OFF;
SET PAGESIZE 0;
select count(*)
from rw_server_queue where job_id in ($jobid)
and status_code in (1,2,3,10);
EOF
temp1=`echo $status_cnt|tr -d [0-9]` 
temp2=${temp1:-"numer"}
if [ $temp2 = "numer" ] 
then
:
else
status_cnt=9999
break
fi
done
echo $status_cnt
}

Desired Results Execution:

Code:
 
+ + check_report_completion 0,14193,14194
+ jobid=0,14193,14194
+ status_cnt=9999
+ [ 9999 -eq 0 ]
+ sleep 15
+ read status_cnt
+ sqlplus -s /@compasp
+ 0<<
whenever sqlerror exit sql.sqlcode; 
SET FEEDBACK OFF;
SET PAGESIZE 0;
select count(*)
from rw_server_queue where job_id in (0,14193,14194)
and status_code in (1,2,3,10);
+ + echo 2
+ tr -d [0-9]
temp1=
+ temp2=numer
+ [ numer = numer ]
+ :
+ [ 2 -eq 0 ]
+ sleep 15
+ read status_cnt
+ sqlplus -s /@compasp
+ 0<<
whenever sqlerror exit sql.sqlcode; 
SET FEEDBACK OFF;
SET PAGESIZE 0;
select count(*)
from rw_server_queue where job_id in (0,14193,14194)
and status_code in (1,2,3,10);
+ + echo 1
+ tr -d [0-9]
temp1=
+ temp2=numer
+ [ numer = numer ]
+ :
+ [ 1 -eq 0 ]
+ sleep 15
+ read status_cnt

Undesired Results Execution:

Code:
 
+ + check_report_completion 0,28030,28031
+ jobid=0,28030,28031
+ status_cnt=9999
+ [ 9999 -eq 0 ]
+ sleep 15
+ read status_cnt
+ sqlplus -s /@compasp
+ 0<<
whenever sqlerror exit sql.sqlcode; 
SET FEEDBACK OFF;
SET PAGESIZE 0;
select count(*)
from rw_server_queue where job_id in (0,28030,28031)
and status_code in (1,2,3,10);
+ + tr -d 2
+ echo 2
temp1=
+ temp2=numer
+ [ numer = numer ]
+ :
+ [ 2 -eq 0 ]
+ sleep 15
+ read status_cnt
+ sqlplus -s /@compasp
+ 0<<
whenever sqlerror exit sql.sqlcode; 
SET FEEDBACK OFF;
SET PAGESIZE 0;
select count(*)
from rw_server_queue where job_id in (0,28030,28031)
and status_code in (1,2,3,10);
+ + echo 1
+ tr -d 2
temp1=1
+ temp2=1
+ [ 1 = numer ]
+ status_cnt=9999
+ break
+ echo 9999

 

10 More Discussions You Might Find Interesting

1. 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

2. 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... (6 Replies)
Discussion started by: ran16
6 Replies

3. 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

4. Shell Programming and Scripting

Need help... Differences in Communication commands

What is the difference between the following commands. Please with example? rsh ssh scp rcp rlogin ftp telnet Cheers.. (3 Replies)
Discussion started by: gwgreen1
3 Replies

5. Shell Programming and Scripting

Automating execution of commands inside a program

I have a program dnapars I execute the program from command line as following: ./dnapars The program then prompts me some message as a user menu from where I have to select a series of options in the order R U Y R. And then I copy the output file (outfile) in another result file. I wrote the... (3 Replies)
Discussion started by: deeptisjains
3 Replies

6. 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

7. 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

8. 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

9. UNIX for Dummies Questions & Answers

Execution of local commands for remote site.

Hi all, I have a problem with ftp execution within unix environment. I'd like to get files on remote and delete them later, but here is too crowd so I can accidentally delete some files. Can I delete only the files I can get to the local folder? I can ask this question with a different... (14 Replies)
Discussion started by: attillam
14 Replies

10. 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
BLOCKDIAG(1)						      General Commands Manual						      BLOCKDIAG(1)

NAME
blockdiag - generate block-diagram image file from spec-text file. SYNOPSIS
blockdiag [options] file DESCRIPTION
This manual page documents briefly the blockdiag commands. blockdiag is a program that generate block-diagram image file from spec-text file. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. For a complete description, see the SEE ALSO. --version show program's version number and exit -h, --help Show summary of options -a, --antialias Pass diagram image to anti-alias filter -c FILE, --config=FILE read configurations from FILE -o FILE write diagram to FILE -f FONT, --font=FONT use FONT to draw diagram --fontmap=FONT use FONTMAP file to draw diagram -s, --separate Separate diagram images for each group -T TYPE Output diagram as TYPE format --nodoctype Do not output doctype definition tags (SVG only) --no-transparency do not make transparent background of diagram (PNG only) SEE ALSO
The programs are documented fully by http://tk0miya.bitbucket.org/blockdiag/build/html/index.html AUTHOR
blockdiag was written by Takeshi Komiya <i.tkomiya@gmail.com> This manual page was written by Kouhei Maeda <mkouhei@palmtb.net>, for the Debian project (and may be used by others). May 9, 2011 BLOCKDIAG(1)
All times are GMT -4. The time now is 08:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy