delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/09/15/14:32:43

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
X-IronPortListener: Outbound_SMTP
From: "Buchbinder, Barry (NIH/NIAID) [E]" <BBuchbinder AT niaid DOT nih DOT gov>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
CC: "'delbydev'" <derrin AT usa DOT net>
Date: Wed, 15 Sep 2010 14:32:16 -0400
Subject: FW: Behaviours of Terminal Versus Script when using "<<"
Message-ID: <0105D5C1E0353146B1B222348B0411A20946F38C95@NIHMLBX02.nih.gov>
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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

delbydev sent the following at Wednesday, September 15, 2010 1:18 PM
>
>Hello Have hunted all over for this one but it seems no one else has
>reported the issue - maybe because they don't use the feature or there
>is something awry with my installation
>
>I write scripts that dart in and out of databases
>
>I bind my Oracle connection string into a number of variables in my
>.profile
>
>ORACLE_HOME=3D'c:\\Oracle\\product\\11.2.0\\dbhome_2' export ORACLE_HOME
>mydbconn=3D"${ORACLE_HOME}\\bin\\sqlplus -s mydbuser/mydbpass AT mydbhost"
>export mydbconn
>
>so when I want to dart into the database - I perform the following from
>the terminal command line ${mydbconn} SQL> SQL> exit
>
>If I have a query I run frequently - I will do something like this
>
>${mydbconn} << FINGather alter session set nls_date_format =3D 'yyyy-mm-dd
>hh24:mi:ss'; select sysdate from dual; FINGather
>
>The << delimiter instructs the terminal to pass all commands between the
>FINGather Labels to the program request (sort of piping but not)
>
>This is great and dandy - and works if I type this into the cygwin
>terminal manually (or paste, which ever)
>
>When I try this from a script I hit issues. I usually want to catch
>the results from the DB query to a file so - let's call my script
>mydbtime.sh
>
>The contents of which are as following
>
>#!/bin/bash echo My DB Time Fetcher > /tmp/myresults.txt date >>
>/tmp/myresults.txt ${mydbconn} << FINGather >> /tmp/myresults.txt alter
>session set nls_date_format =3D 'yyyy-mm-dd hh24:mi:ss'; select sysdate
>from dual; FINGather
>
>After editing chmod 755 mydbtime.sh To run as standard ./mydbtime
>
>There is a gotcha some where because I know definitely this line is
>working when inside a script
>
>The contents of the /tmp/myresults.txt output always shows the results
>of the echo command and the date command - but never the results of the
>${mydbconn}
>
>${mydbconn} << FINGather >> /tmp/myresults.txt
>
>_____________ If I remove the date and echo commands out :
>
>#!/bin/bash ${mydbconn} << FINGather > /tmp/myresults.txt alter session
>set nls_date_format =3D 'yyyy-mm-dd hh24:mi:ss'; select sysdate from dual;
>FINGather
>
>the date stamp and contents of the /tmp/myresults.txt are always
>refreshed - just with no results so I know that "${mydbconn} <<
>FINGather > /tmp/myresults.txt" is processing but the results from
>dbserver are not being passed back - in fact - I don't think it is
>connecting to DB at all because even a long query completes immediately.
>
>Presently - to run my scripts I perform the following process
>
>cat mydbtime.sh
>
>Copy and Paste the full contents straight onto the Terminal Command line
>This works perfectly
>
>Does anyone have issues with this?
>
>I have found a workaround that works perfectly - using the supplied
>minnty terminal - but was hoping not to build too many dependencies on
>the cygwin "windows" - I will work with minnty - but does anyone know if
>this is shipped as standard - because it is not the first shortcut in
>the Cygwin folder - had I found this before I would have been singing
>from the roof tops at the joy of being able to move away from the MS
>Windows CMD terminal - will support for CMD terminal be dropped or have
>I landed on a well kept secret
>
>so two questions 1) Does the MS CMD Terminal support << in scripts
>(presently not in my installation) - I can't be sure but I think it used
>to work on older environment 2) Is minnty a default standard terminal
>that will ship with all future builds of cygwin?
>
>Environment Details Windows 7
>
>Great job guys - love this product - Command Shell is trying to catch up
>- think they have a long way to go
>
>Cheers
>
>Delbydev

I use Oracle's plus80.exe on XP in a cygwin/dash script.

Although I do not use <<, I feed commands to plus80.exe directly by piping
into it or putting commands into a file and use "plus80 @file".  In both
cases, I convert to DOS line endings beforehand with "u2d -D".

So I'd play with your line endings and see whether that helps.  You are
probably giving it a simple \n while sqlplus.exe is looking for \r and/or
\r\n.

Good luck.

- Barry
  Disclaimer: Statements made herein are not made on behalf of NIAID.


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019