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
mfontset_lookup(3m17n)						 The m17n Library					    mfontset_lookup(3m17n)

NAME
mfontset_lookup - Lookup a fontset. SYNOPSIS
MPlist * mfontset_lookup (MFontset * fontset, MSymbol script, MSymbol language, MSymbol charset) DESCRIPTION
Lookup a fontset. The mfontset_lookup() function lookups fontset and returns a plist that describes the contents of fontset corresponding to the specified script, language, and charset. If script is Mt, keys of the returned plist are script name symbols for which some fonts are specified and values are NULL. If script is a script name symbol, the returned plist is decided by language. o If language is Mt, keys of the plist are language name symbols for which some fonts are specified and values are NULL. A key may be Mt which means some fallback fonts are specified for the script. o If language is a language name symbol, the plist is a FONT-GROUP for the specified script and language. FONT-GROUP is a plist whose keys are FLT (FontLayoutTable) name symbols (Mt if no FLT is associated with the font) and values are pointers to MFont. o If language is Mnil, the plist is fallback FONT-GROUP for the script. If script is Mnil, the returned plist is decided as below. o If charset is Mt, keys of the returned plist are charset name symbols for which some fonts are specified and values are NULL. o If charset is a charset name symbol, the plist is a FONT-GROUP for the charset. o If charset is Mnil, the plist is a fallback FONT-GROUP. RETURN VALUE
It returns a plist describing the contents of a fontset. The plist should be freed by m17n_object_unref(). COPYRIGHT
Copyright (C) 2001 Information-technology Promotion Agency (IPA) Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>. Version 1.6.2 12 Jan 2011 mfontset_lookup(3m17n)
All times are GMT -4. The time now is 07:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy