public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: Piping output from sqlplus
@ 2004-12-17 20:59 Bakken, Luke
  2004-12-20 15:25 ` Chuck
  0 siblings, 1 reply; 17+ messages in thread
From: Bakken, Luke @ 2004-12-17 20:59 UTC (permalink / raw)
  To: cygwin

> 
> I need a korn shell that will handle the windows-like path names
> (pdksh),  and where "read" executes in the same shell that called it
> (ksh '93).

Keep wishing. There are other ways of doing what you need to do with
sqlplus without using a pipe and read.

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

^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: Piping output from sqlplus
@ 2004-12-16 21:36 Bakken, Luke
  2004-12-17 12:59 ` Chuck
  2004-12-17 16:26 ` Chuck
  0 siblings, 2 replies; 17+ messages in thread
From: Bakken, Luke @ 2004-12-16 21:36 UTC (permalink / raw)
  To: Chuck, cygwin

> Why would ksh behave differently under Cygwin than under Solaris?

cygwin ksh is pdksh. The specific set of code you gave does not work in
pdksh. Read about it here:
http://web.cs.mun.ca/~michael/pdksh/

"Its weak points are that there are still a few differences from ksh88
(the major one is that `echo hi | read x' does not set x in the current
shell - the read is done in a separate process). See the NOTES file in
the distribution for more details."

You can get a Cygwin ksh from www.kornshell.com

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

^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: Piping output from sqlplus
@ 2004-12-16 21:33 Buchbinder, Barry (NIH/NIAID)
  0 siblings, 0 replies; 17+ messages in thread
From: Buchbinder, Barry (NIH/NIAID) @ 2004-12-16 21:33 UTC (permalink / raw)
  To: cygwin

At Thursday, December 16, 2004 3:57 PM, Chuck wrote:
> 
> Buchbinder, Barry (NIH/NIAID) wrote:
>> At Thursday, December 16, 2004 3:29 PM, 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@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. 
>>> 
>>> If I remove the "read line", the output displays on the tty just
>>> fine. 
>>> 
>>> I though it might be related to the line end characters so I tried
>>> converting them with the dos2unix filter. Didn't work. Neither did
>>> tr -d \\r. Both ways, $line still ends up being empty.
>>> 
>>> If I replace the "read line" with "od -c" to dump the characters, it
>>> shows the one line as expected.
>>> 
>>> If I redirect the output to a file, the file contains one line as
>>> expected. 
>>> 
>>> If I try to read the output into a variable, I get an empty variable
>>> 
>>> Any ideas?
>> 
>> If the output shows up OK in a file, do
>> VAR="$(cat file)"
> 
> That may work but it misses the point. I'm writing a script and I want
> it to work on Cygwin and unix.
> 
> BTW the shell I'm using is ksh.

Well, I don't have access to a Unix or Linux machine, but I would have
thought outputting a file and filing the variable by cat'ting it would work
there, too.

I don't use ksh.  If what I suggested does not work there, something like
the following should.

VAR=`cat file`

If the trailing \n gets converted into an undesirable space, you could
always do

VAR=`cat file | tr -d '\n'`

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

^ permalink raw reply	[flat|nested] 17+ messages in thread
* RE: Piping output from sqlplus
@ 2004-12-16 20:48 Buchbinder, Barry (NIH/NIAID)
  2004-12-16 21:11 ` Chuck
  0 siblings, 1 reply; 17+ messages in thread
From: Buchbinder, Barry (NIH/NIAID) @ 2004-12-16 20:48 UTC (permalink / raw)
  To: cygwin

At Thursday, December 16, 2004 3:29 PM, Chuck wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 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@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.
> 
> If I remove the "read line", the output displays on the tty just fine.
> 
> I though it might be related to the line end characters so I tried
> converting them with the dos2unix filter. Didn't work. Neither did tr
> -d \\r. Both ways, $line still ends up being empty.
> 
> If I replace the "read line" with "od -c" to dump the characters, it
> shows the one line as expected.
> 
> If I redirect the output to a file, the file contains one line as
> expected. 
> 
> If I try to read the output into a variable, I get an empty variable
> 
> Any ideas?

If the output shows up OK in a file, do
VAR="$(cat file)"

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

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Piping output from sqlplus
@ 2004-12-16 20:29 Chuck
  2004-12-16 20:39 ` Christopher Faylor
  0 siblings, 1 reply; 17+ messages in thread
From: Chuck @ 2004-12-16 20:29 UTC (permalink / raw)
  To: cygwin

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

If I remove the "read line", the output displays on the tty just fine.

I though it might be related to the line end characters so I tried
converting them with the dos2unix filter. Didn't work. Neither did tr -d
\\r. Both ways, $line still ends up being empty.

If I replace the "read line" with "od -c" to dump the characters, it
shows the one line as expected.

If I redirect the output to a file, the file contains one line as expected.

If I try to read the output into a variable, I get an empty variable

Any ideas?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBwfAbzIf+rZpn0oQRAtcxAJ46XUAtR57DsuKAXj7nBFmR1V/QNQCfX/da
09U1qXkDrheltOlQrMSubzU=
=pQxI
-----END PGP SIGNATURE-----


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

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2004-12-21 16:42 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-17 20:59 Piping output from sqlplus Bakken, Luke
2004-12-20 15:25 ` Chuck
2004-12-20 16:15   ` Igor Pechtchanski
2004-12-20 16:43   ` Christopher Faylor
2004-12-21 16:42     ` Chuck
  -- strict thread matches above, loose matches on Subject: below --
2004-12-16 21:36 Bakken, Luke
2004-12-17 12:59 ` Chuck
2004-12-17 13:06   ` Dave Korn
2004-12-17 16:26 ` Chuck
2004-12-17 16:35   ` Christopher Faylor
2004-12-17 20:17     ` Chuck
2004-12-16 21:33 Buchbinder, Barry (NIH/NIAID)
2004-12-16 20:48 Buchbinder, Barry (NIH/NIAID)
2004-12-16 21:11 ` Chuck
2004-12-16 20:29 Chuck
2004-12-16 20:39 ` Christopher Faylor
2004-12-16 21:19   ` Chuck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).