public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* 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

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

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

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

* Re: Piping output from sqlplus
  2004-12-16 20:39 ` Christopher Faylor
@ 2004-12-16 21:19   ` Chuck
  0 siblings, 0 replies; 17+ messages in thread
From: Chuck @ 2004-12-16 21:19 UTC (permalink / raw)
  To: cygwin

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

Christopher Faylor wrote:
| 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@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
|

Actually I'm using ksh.

$ echo hello | read LINE
$ echo $LINE

$

Looks like you said. I know this is not the expectd behaviour for ksh
though. On Solaris ksh ...

Solaris$ echo hello | read LINE
Solaris$ echo $LINE
hello
Solaris$

Why would ksh behave differently under Cygwin than under Solaris?


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

iD8DBQFBwfYpzIf+rZpn0oQRAtnYAJ9jBdGzER29YzWnMOmREeQJv+fasQCdGFQc
jRPqneau2f7PFhDXtwKGsn4=
=bY4I
-----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

* Re: Piping output from sqlplus
  2004-12-20 16:43   ` Christopher Faylor
@ 2004-12-21 16:42     ` Chuck
  0 siblings, 0 replies; 17+ messages in thread
From: Chuck @ 2004-12-21 16:42 UTC (permalink / raw)
  To: cygwin

Christopher Faylor wrote:
> On Mon, Dec 20, 2004 at 10:02:22AM -0500, Chuck wrote:
> 
>>Bakken, Luke wrote:
>>
>>>>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.
>>
>>I have dozen's of ksh scripts already written and running on other 
>>platforms. I'm not going to change them all just to accomodate a 
>>weakness in Cygwin, or more precisely pdksh.
> 
> 
> So you've got dozens of ksh scripts and your method of getting them
> working on cygwin is to wish real hard that something changes?  You must
> not want to get things working on windows very much then.
> 

I don't really *need* them to work on Windows. I just thought I could 
use Cygwin to develop and maintain them while I'm on my laptop and not 
connected. The final destination of all my ksh scripts will be Solaris. 
That's where they need to run

I'll be able to live with the ksh from www.kornshell.com. It's closer to 
what Sun distributes.


--
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-20 15:25 ` Chuck
  2004-12-20 16:15   ` Igor Pechtchanski
@ 2004-12-20 16:43   ` Christopher Faylor
  2004-12-21 16:42     ` Chuck
  1 sibling, 1 reply; 17+ messages in thread
From: Christopher Faylor @ 2004-12-20 16:43 UTC (permalink / raw)
  To: cygwin

On Mon, Dec 20, 2004 at 10:02:22AM -0500, Chuck wrote:
>Bakken, Luke wrote:
>>>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.
>
>I have dozen's of ksh scripts already written and running on other 
>platforms. I'm not going to change them all just to accomodate a 
>weakness in Cygwin, or more precisely pdksh.

So you've got dozens of ksh scripts and your method of getting them
working on cygwin is to wish real hard that something changes?  You must
not want to get things working on windows very much then.

--
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-20 15:25 ` Chuck
@ 2004-12-20 16:15   ` Igor Pechtchanski
  2004-12-20 16:43   ` Christopher Faylor
  1 sibling, 0 replies; 17+ messages in thread
From: Igor Pechtchanski @ 2004-12-20 16:15 UTC (permalink / raw)
  To: Chuck; +Cc: cygwin

On Mon, 20 Dec 2004, Chuck wrote:

> Bakken, Luke wrote:
> > > 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.
>
> I have dozen's of ksh scripts already written and running on other
> platforms. I'm not going to change them all just to accomodate a
> weakness in Cygwin, or more precisely pdksh.

Cygwin isn't the only platform where ksh is pdksh.  You can't change all
the platforms.  If you want your scripts to be truly portable, you should
try to accomodate the idiosyncracies of each platform.  As mentioned
above, it's rather easy to change the scripts so that they work on all
platforms (including Cygwin).  You can also test whether your construct
works, and if it doesn't, have a bit of pdksh-specific code.

Basically (again, as others mentioned), Cygwin's main ksh will stay pdksh
unless someone (i.e., you) packages and offers to maintain the "real" ksh.
If you decide to do this[*], please review the packaging instructions at
<http://cygwin.com/setup.html>, and good luck.  It might also help to
review the prior discussions on the issue (search the cygwin-apps archives
for ksh93).
	Igor
[*] You'll also need to coordinate with the pdksh maintainer (me)
regarding the naming of executables and symlink policies.  Such
coordination usually happens on the cygwin-apps mailing list (which all
maintainers have to read).  When you ITP the package, this will come up.
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

--
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-17 20:59 Bakken, Luke
@ 2004-12-20 15:25 ` Chuck
  2004-12-20 16:15   ` Igor Pechtchanski
  2004-12-20 16:43   ` Christopher Faylor
  0 siblings, 2 replies; 17+ messages in thread
From: Chuck @ 2004-12-20 15:25 UTC (permalink / raw)
  To: cygwin

Bakken, Luke wrote:
>>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.
> 

I have dozen's of ksh scripts already written and running on other 
platforms. I'm not going to change them all just to accomodate a 
weakness in Cygwin, or more precisely pdksh.


--
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-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-17 16:35   ` Christopher Faylor
@ 2004-12-17 20:17     ` Chuck
  0 siblings, 0 replies; 17+ messages in thread
From: Chuck @ 2004-12-17 20:17 UTC (permalink / raw)
  To: cygwin

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

Christopher Faylor wrote:
| On Fri, Dec 17, 2004 at 11:26:15AM -0500, Chuck wrote:
|
|>Bakken, Luke wrote:
|>
|>>>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
|>>
|>
|>This is working just perfectly thanks. I would like to note (for the
|>archives) that this ksh does not support the -l option. If you want to
|>use it for a login shell so that it runs /etc/profile and $HOME/.profile
|>automatically, make a copy of it named -ksh and run that from your
|>windows batch file. I tried just creating a symlink named -ksh first,
|>but Windows didn't like it.
|
|
| I'd like to note for the archives also that I'd like to get the real
version
| of ksh into the cygwin distribution.
|
| This comes up from time to time.  The first time it happened someone
was insisting
| that they needed to change the Cygwin DLL for this to happen and I had
reservations
| about the licensing status of some of the changes since the person had
also seen
| U/WIN sources.  Then, somehow, ksh was built without the need to
change cygwin and
| a cygwin ksh package was going to show up any second now.
|
| Well, years later, we still don't have a ksh.
|
| Anyone want to take the plunge?
|
| cgf
|

I have come across one other problem with ksh'93 for Cygwin from
www.kornshell.com. It chokes on path names that don't follow the pure
unix convention. For example c:/oracle/ora92 causes problems but
/cygdrive/c/oracle/ora92 does not.

It doesn't like //server_name/share_name either.

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).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD4DBQFBwz7LzIf+rZpn0oQRAvIYAJjpbQtTNIbQ63Kt0Bd57jvlKbqHAKCbeReO
mCrlL3wnkpwOLpq0bb04OQ==
=ijjd
-----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

* Re: Piping output from sqlplus
  2004-12-17 16:26 ` Chuck
@ 2004-12-17 16:35   ` Christopher Faylor
  2004-12-17 20:17     ` Chuck
  0 siblings, 1 reply; 17+ messages in thread
From: Christopher Faylor @ 2004-12-17 16:35 UTC (permalink / raw)
  To: cygwin

On Fri, Dec 17, 2004 at 11:26:15AM -0500, Chuck wrote:
>Bakken, Luke wrote:
>>>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
>>
>
>This is working just perfectly thanks. I would like to note (for the 
>archives) that this ksh does not support the -l option. If you want to 
>use it for a login shell so that it runs /etc/profile and $HOME/.profile 
>automatically, make a copy of it named -ksh and run that from your 
>windows batch file. I tried just creating a symlink named -ksh first, 
>but Windows didn't like it.

I'd like to note for the archives also that I'd like to get the real version
of ksh into the cygwin distribution.

This comes up from time to time.  The first time it happened someone was insisting
that they needed to change the Cygwin DLL for this to happen and I had reservations
about the licensing status of some of the changes since the person had also seen
U/WIN sources.  Then, somehow, ksh was built without the need to change cygwin and
a cygwin ksh package was going to show up any second now.

Well, years later, we still don't have a ksh.

Anyone want to take the plunge?

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/

^ 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
  2004-12-17 16:35   ` Christopher Faylor
  1 sibling, 1 reply; 17+ messages in thread
From: Chuck @ 2004-12-17 16:26 UTC (permalink / raw)
  To: cygwin

Bakken, Luke wrote:
>>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
> 

This is working just perfectly thanks. I would like to note (for the 
archives) that this ksh does not support the -l option. If you want to 
use it for a login shell so that it runs /etc/profile and $HOME/.profile 
automatically, make a copy of it named -ksh and run that from your 
windows batch file. I tried just creating a symlink named -ksh first, 
but Windows didn't like it.


--
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-17 12:59 ` Chuck
@ 2004-12-17 13:06   ` Dave Korn
  0 siblings, 0 replies; 17+ messages in thread
From: Dave Korn @ 2004-12-17 13:06 UTC (permalink / raw)
  To: cygwin

> -----Original Message-----
> From: cygwin-owner On Behalf Of Chuck
> Sent: 17 December 2004 12:59

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Bakken, Luke wrote:
> |>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
> |
> 
> That explains it. I'll check out the one on www.kornshell.com. Thanks.
> 


  At this stage of the proceedings it is traditional for me to have to explain
that I am no relation.... :)

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


--
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 13:06   ` Dave Korn
  2004-12-17 16:26 ` Chuck
  1 sibling, 1 reply; 17+ messages in thread
From: Chuck @ 2004-12-17 12:59 UTC (permalink / raw)
  To: cygwin

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

Bakken, Luke wrote:
|>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
|

That explains it. I'll check out the one on www.kornshell.com. Thanks.

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

iD8DBQFBwtgnzIf+rZpn0oQRAtz2AJ9Rz+JyRyZtn8MlPtlaXf0PXVQ4PgCggMzb
kq7eOjE1X4yPoZl09CuqeZU=
=45me
-----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

* 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, 0 replies; 17+ messages in thread
From: Chuck @ 2004-12-16 21:11 UTC (permalink / raw)
  To: cygwin

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

Buchbinder, Barry (NIH/NIAID) wrote:
| 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)"
|

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.

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

iD8DBQFBwfaHzIf+rZpn0oQRAvKQAJ9WYJ6CbGrEeDwN9lMg2fzOIGsiOgCffjyz
BxriTOuv4IqT3zdFMHUesIY=
=jJGJ
-----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

* 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

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-16 20:29 Piping output from sqlplus Chuck
2004-12-16 20:39 ` Christopher Faylor
2004-12-16 21:19   ` Chuck
2004-12-16 20:48 Buchbinder, Barry (NIH/NIAID)
2004-12-16 21:11 ` Chuck
2004-12-16 21:33 Buchbinder, Barry (NIH/NIAID)
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-17 20:59 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

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