sqlplus and end-of-line problem in shell script code
Fri Sep 29 15:10:00 GMT 2006
Thomas Porschberg wrote:
> I want to use our shell script collection which includes sqlplus calls
> under Cygwin.
> I have the following problem with this code snippet:
> RESULT=`sqlplus -s myuser/mypasswd@MYDB <<EOF
> SET FEEDBACK OFF;
> SET PAGESIZE 0;
> SELECT '42' FROM DUAL;
> if test "$RESULT" = "42" ; then
> echo "Result is 42..."
> echo "Result is not 42 ??!"
> When I run the script on UNIX it prints "Result is 42..." which is OK.
> When I run the script under Cygwin the result is: "Result is not 42??!"
> The reason is that under Cygwin the result of the SELECT are 3
> characters "42" "CR" "LF" (instead of 2 characters "42" and "LF").
> I did not found a way to convince sqlplus to produce UNIX-EOLs on
> Windows. Does anyone know how to solve the problem without changing
> the code itself ?
Um, if by "the code" you meant the above script, then no. Otherwise it
looks like you could drop a '| d2u' (or '| sed s/\r//g') in there. I
forget though if you want:
RESULT=`app | d2u << EOF
RESULT=`app << EOF
EOF | d2u`
...or possibly neither. At any rate, that's a question of shell syntax;
get that right and it seems it should work.
My preferred shell is Christian. It's Bourne Again.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
More information about the Cygwin