[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
RE: [sqr-users] SQR return status 0 if missing input parameter
- Subject: RE: [sqr-users] SQR return status 0 if missing input parameter
- From: "Moran, Patrick T." <Patrick.Moran@trincoll.edu>
- Date: Wed, 8 Feb 2006 11:43:22 -0500
- Delivery-date: Wed, 08 Feb 2006 11:42:59 -0500
- List-id: "This list is for discussion about the SQR database reportinglanguage from Hyperion Solutions." <sqr-users.sqrug.org>
- Thread-index: AcYszsXBP2nrbywhRgW2U9M5uwEgkg==
- Thread-topic: [sqr-users] SQR return status 0 if missing input parameter
Terence,
I believe the problem you are having is related to how the UNIX (HP/UX
in your case) shell handles the "read" command.
The "read" shell command reads an entire line from the input, either
from a file specified (as in your case) or from stdin. When you code
"read p1 p2 p3", the first "word" of the input line read from the file
(i.e. the characters up to a space, tab, or "new line" character) is
stored in the variable "p1", the second "word" in "p2", and the third
"word" in "p3".
But suppose, as you state, that the input line contains only a single
value (only a single "word"). Then the entire line is stored in "p1"
and the variables "p2" and "p3" contain null strings. These values are
then used as parameters to your SQR program.
The way around this is to:
1. Use your input redirect from parm.txt at the command line when you
execute your shell script, instead of as an object of the "while".
2. Read your variables outside your while loop in your shell script.
3. Check for null strings for your variables p1, p2, p3 and react
accordingly.
I hope this helps.
Pat
-----Original Message-----
From: Terence Yau [mailto:terenceyau@yahoo.com]
Sent: Wednesday, February 01, 2006 9:42 PM
To: sqr-users@sqrug.org
Subject: [sqr-users] SQR return status 0 if missing input parameter
To all
SQR/8.1/HP 9000/HPUX B.11.00/Oracle 8.1.7
I write a new SQR program X with three input
parameters.
begin-program
input $a 'Enter a:'
input $b 'Enter b:'
input $c 'Enter c:'
end-program
If I run the program X in batch mode ( sqrt X a b c
), the program works OK too.
If I miss one or more of the parameters, the program
abends with "(SQR 2500) Error getting INPUT." This
is perfectly fine too.
Since I need to run the program X a few times with
different parameters, I set up a script like this
while read p1 p2 p3
do
sqrt X p1 p2 p3
done < parm.txt
where parm.txt consists of 2 lines:
a b c
e f g
The script runs successful with this parm.txt.
If I only have 'a' and miss the 'b' and 'c' in the
first line of parm.txt file, the program prompts
'Enter b:' and 'Enter c:' on the screen,
wait for a few seconds, return a status of zero
without processing the next line ( e f g ).
Do any of you know why ZERO is returned? How to
re-solve this?
Terence
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users