| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,SPF_HELO_PASS,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <29720777.post@talk.nabble.com> |
| Date: | Wed, 15 Sep 2010 10:18:20 -0700 (PDT) |
| From: | delbydev <derrin AT usa DOT net> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Behaviours of Terminal Versus Script when using "<<" |
| 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 |
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='c:\\Oracle\\product\\11.2.0\\dbhome_2' export ORACLE_HOME
mydbconn="${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 = '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 = '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 = '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 - infact - 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
--
View this message in context: http://old.nabble.com/Behaviours-of-Terminal-Versus-Script-when-using-%22%3C%3C%22-tp29720777p29720777.html
Sent from the Cygwin list mailing list archive at Nabble.com.
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |