delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Date: | Thu, 16 Dec 2004 15:40:05 -0500 |
From: | Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: Piping output from sqlplus |
Message-ID: | <20041216204005.GA26201@trixie.casa.cgf.cx> |
Reply-To: | cygwin AT cygwin DOT com |
References: | <cpsr6t$45c$1 AT sea DOT gmane DOT org> |
Mime-Version: | 1.0 |
In-Reply-To: | <cpsr6t$45c$1@sea.gmane.org> |
User-Agent: | Mutt/1.4.1i |
On Thu, Dec 16, 2004 at 03:29:16PM -0500, Chuck wrote: >I'm having a strange problem reading the output from sqlplus in Cygwin. >Sqlplus is a windows command line program used to access oracle >databases. My command looks something like this... > >sqlplus -s <<! | read line >user/password AT database >set pagesize 0 linesize 200 feedback off tab off >select col1||chr(9)||col2 >from table; >! > >This should output one line to stdout with the two values separated by a >tab character. The read command should read it into the variable $line. >On my Solaris system it works perfectly. In Cygwin, $line is empty. Just to demonstrate what you're seeing without the sqlplus requirement: bash$ echo hello | read line bash$ echo $line bash$ The reason for the behavior is apparently that when you use read in a pipe like this bash and ash fork a separate process so the variable only exists very briefly in that process and `line' is never defined in the main process. zsh does what you'd expect, so if you can use zsh instead of bash, that would be a solution. Otherwise, you probably will have to experiment with setting IFS and using either $(sqlplus) or `sqlplus` . cgf -- 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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |