Eric Peterson a écrit :
I have the following test script using $() to capture the return
values from a SQLPLUS command. I also want to capture the return
code to identify if an error occurred. Running this on my Mac and
Linux box called Dorado, all works well, but the same script on SunOS
box called Blenny it does not (see error below). But if I change the
$() to backticks ` then it works.
please, next time, try to limit your lines to 76 chars. thanks.
(thanks to ff reformat feature :-)
I was under the impression backticks and $() syntax were essentially
the same. Can someone help to understand the differences? Personally
I like the $() syntax more then the backticks. The backticks
sometimes get lost when looking through a bunch of code.
http://www.in-ulm.de/~mascheck/various/cmd-subst/
hmmm.. I was also looking at my return code, it does not change from
0. If I put a syntax error in the query, like rename user_tables to
xzyz, it still returns 0. I guess showing that the sqlplus command
finished successfully but did not transfer the exit value to $?. I
was hoping to get those two separate values. For example, in the
Blenny test below, I expect to see the text "Database Error [1]"
before printing the return value text. Any ideas?
try w/o the lower ( ... ) to see if the problem is the () ?
alternative, put your sqlplus code w/in a function such as :
function foo {
sqlplus ... << EOF
sqlcode
EOF
}
or even, but in this case, you have to pass the search variable as an
sqlplus parameter
function bar { sqlplus ... ; } << EOf
sqlcode
EOF
then
rv=$(function)
however, I've tryed the following test cases under some shell,
then see the results below :
1/
x=$(cat << EOF
hi
EOF
)
echo $x
2/ is this supposed to work ?
x=$(cat) << EOF
hi
EOF
echo $x
cygwin 1.7 / bash 3.2.49
1/ ok 2/ hang until ^D
cygwin 1.7 / pdksh 5.2.14
1/ ok 2/ ok
cygwin 1.7 / ksh88 g (yes, I've one :-)
1/ ok 2/ hang until ^D
cygwin 1.7 / ksh93 t+
1/ code dump 2/ hang until ^D then cat seems to still run !
[e]0;wa]n[e[32...@h [e[33m]w[e[0m]nv$ x=$(cat) << EOF
> hi
> EOF
^D
[e]0;wa]n[e[32...@h [e[33m]w[e[0m]nv$ echo $x
echo $x
[e]0;wa]n[e[32...@h [e[33m]w[e[0m]nv$ EOF
ksh93: EOF: not found [No such file or directory]
[e]0;wa]n[e[32...@h [e[33m]w[e[0m]nv$ echo $x
echo $x
[e]0;wa]n[e[32...@h [e[33m]w[e[0m]nv$ ^D
argh! can't connect to my work to test other oses...
Regards,
Cyrille Lefevre
--
mailto:[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users