X-Spam-Check-By: sourceware.org
To: cygwin@cygwin.com
From: mwoehlke <mwoehlke@tibco.com>
Subject:  Re: sqlplus and end-of-line problem in shell script code
Date:  Fri, 29 Sep 2006 10:08:04 -0500
Lines: 48
Message-ID: <efjcsl$iii$1@sea.gmane.org>
References:  <20060929102628.49430820@porschberg.osp-dd.de>
Mime-Version:  1.0
Content-Type:  text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding:  7bit
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.0
In-Reply-To: <20060929102628.49430820@porschberg.osp-dd.de>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Thomas Porschberg wrote:
> Hi,
> I want to use our shell script collection which includes sqlplus calls
> under Cygwin.
> I have the following problem with this code snippet:
> 
> #!/bin/bash
> 
> RESULT=`sqlplus -s myuser/mypasswd@MYDB <<EOF
> SET FEEDBACK OFF;
> SET PAGESIZE 0;
> SELECT '42' FROM DUAL;
> EOF`
> 
> if test "$RESULT" = "42" ; then
> echo "Result is 42..."
> else
> echo "Result is not 42 ??!"
> fi
> 
> 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
input
EOF`

or

RESULT=`app << EOF
input
EOF | d2u`

...or possibly neither. At any rate, that's a question of shell syntax; 
get that right and it seems it should work.

-- 
Matthew
My preferred shell is Christian. It's Bourne Again.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

