This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Behaviours of Terminal Versus Script when using "<<"


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@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]