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
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 05:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy