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
fntsample(1)						      General Commands Manual						      fntsample(1)

NAME
fntsample - PDF and PostScript font samples generator SYNOPSIS
fntsample [ OPTIONS ] -f FONT-FILE -o OUTPUT-FILE fntsample -h DESCRIPTION
fntsample program can be used to generate font samples that show Unicode coverage of the font and are similar in appearance to Unicode charts. Samples can be saved into PDF (default) or PostScript file. OPTIONS
fntsample supports the following options. --font-file, -f FONT-FILE Make samples of FONT-FILE. --font-index, -n IDX Font index for FONT-FILE specified using --font-file option. Useful for files that contain multiple fonts, like TrueType Collec- tions (.ttc). By default font with index 0 is used. --output-file, -o OUTPUT-FILE Write output to OUTPUT-FILE. --other-font-file, -d OTHER-FONT Compare FONT-FILE with OTHER-FONT. Glyphs added to FONT-FILE will be highlighted. --other-index, -m IDX Font index for OTHER-FONT specified using --other-font-file option. --postscript-output, -s Use PostScript format for output instead of PDF. --svg, -g Use SVG format for output. The generated document contains one page. Use range selection options to specify which. --print-outline, -l Print document outlines data to standard output. This data can be used to add outlines (aka bookmarks) to resulting PDF file with pdfoutline program. --include-range, -i RANGE Show characters in RANGE. --exclude-range, -x RANGE Do not show characters in RANGE. --style, -t "STYLE: VAL" Set STYLE to value VAL. Run fntsample with option --help to see list of styles and default values. --help, -h Display help text and exit. Parameter RANGE for -i and -x can be given as one integer or a pair of integers delimited by minus sign (-). Integers can be specified in decimal, hexadecimal (0x...) or octal (0...) format. One integer of a pair can be missing (-N can be used to specify all characters with codes less or equal to N, and N- for all characters with codes greather or equal to N). Multiple -i and -x options can be used. EXAMPLES
Make PDF samples for font.ttf and write them to file samples.pdf: fntsample -f font.ttf -o samples.pdf Make PDF samples for font.ttf, compare it with oldfont.ttf and highlight new glyphs. Write output to file samples.pdf: fntsample -f font.ttf -d oldfont.ttf -o samples.pdf Make PostScript samples for font.ttf and write output to file samples.ps. Show only glyphs for characters with codes less or equal to U+04FF but exclude U+0370-U+03FF: fntsample -f font.ttf -s -o samples.ps -i -0x04FF -x 0x0370-0x03FF Make PDF samples for font.ttf and save output to file samples.pdf adding outlines to it: fntsample -f font.ttf -o temp.pdf -l > outlines.txt pdfoutline temp.pdf outlines.txt samples.pdf AUTHOR
Copyright (C) 2007 Eugeniy Meshcheryakov <eugen@debian.org> Homepage: <http://fntsample.sourceforge.net/> SEE ALSO
pdfoutline(1) 2010-10-14 fntsample(1)
All times are GMT -4. The time now is 08:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy