Are you actually using the Bourne shell to test? In HP-UX, the Bourne shell is found in /usr/old/bin/sh and unless you specify the desired interpreter (shell) as your first line, the script will be run by whatever shell you are using at the moment. Always code the interpreter:
#/usr/old/bin/sh
or
#/usr/bin/sh
And just like with Bourne, POSIX, Korn and BASH, you can trace the execution with set -x or run the script with the interpreter and the -x flag as in:
/usr/old/bin/sh -x myscript
Note that tracing is always sent to stderr so to pipe everything into more or pg, redirect stderr:
/usr/bin/sh -x myscript 2>&1 | more
As far as the OPEN not working, the result of the program is TWO lines, not one. Although octal it's a pain to read, it's clear that your sqlplus program returns a blank line followed by OPEN. So there are several ways to solve this:
STATUS=$(echo "$STATUS | tail -1)
but this suffers from the prblem that the sqlplu program may be unstable (not dependable to always write a blank line), so just use grep:
if echo "$STATUS" | grep -q OPEN
then
echo "Database is OPEN"
else
echo "Database not open, status is \""$STATUS"\""
fi
(note the use of extra " in the not-open status--it will delimit the beginning and end of the actual string)
BTW: A much, much easier way to decode strings is to use hex:
echo "$STATUS" | xd -xc
Note that od and xd are the same program, so you can also use this:
echo "$STATUS" | od -xc
Bill Hassell, sysadmin