Re: Using native win32 psql.exe using alternative cygwin

Lists: pgsql-general
From: Richard van den Berg <richard(dot)vandenberg(at)trust-factory(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Using native win32 psql.exe using alternative cygwin terminal
Date: 2005-11-04 10:50:38
Message-ID: 436B3CFE.5090408@trust-factory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I just installed postgresql 8.1-rc1 on a Windows 2003 machine. Since I
like psql a lot, and hate the cmd.exe terminal, I use puttycyg instead.

When I tried using psql.exe in a puttycyg terminal, after entering my
password for the database, the screen just "hangs". When I do the same
from a cygwin cmd.exe terminal, everything works. Another detail: the
password using cmd.exe is hidden, using puttycyg it is shown.

The exact same behaviour is shown when using the OpenSSH daemon (under
cygwin) and logging in to it from remote (putty client or OpenSSH client).

It looks like there is a problem with the interactive mode. When I run:

psql -d postgres -c 'select * from pg_tables limit 1;'

the output is shown just fine. I tried different TERM settings, but they
made no difference.

Is there something I can do to make this combination work? I'd gladly do
more tests..

Sincerely,

--
Richard van den Berg, CISSP
-------------------------------------------
Trust Factory B.V. | www.dna-portal.net
Bazarstraat 44a | www.trust-factory.com
2518AK The Hague | Phone: +31 70 3620684
The Netherlands | Fax : +31 70 3603009
-------------------------------------------


From: "Bill Bartlett" <bbartlett(at)meridianemr(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using native win32 psql.exe using alternative cygwin terminal
Date: 2005-11-04 20:42:20
Message-ID: 037401c5e180$42583e30$1e00a8c0@bartletthome.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I hit this exact same problem, and my initial reaction was the same as
yours -- psql was "hanging". After much head-banging, I discovered that
it is not in fact hanging, but is instead getting confused by being run
from inside Putty, Cygwin, xterm, rxvt terminal, etc. Because psql is
not being run from a native Win32 console window, it puts itself into
non-interactive mode, so it shows no prompts, allows no line editing,
shows no command history, etc. But it is actually running. (And I
couldn't find any combination of TERM settings, security settings or any
other settings that would get around this.)

Unfortunately, at the moment there is no command-line flag to force psql
into "interactive" mode. I have the code (courtesy of Bruce Momjian) to
add a flag such as this, but I haven't had time to set up the
environment to actually recompile psql.

Alternatively, you can run Cygwin's version of psql against the native
Win32 PostgreSQL 8 database, assuming you install the base Cygwin
environment. This does work fine, and gives you the added benefit of
including "readline" support (something compiled out of the native Win32
version of psql), so tab-completion works even in the Windows
environment. Two caveats, however:

1) You can't install _just_ psql from the Cygwin setup -- you'll have to
install the complete PostgreSQL environment (database and all), then
copy just the psql-related files (psql.exe and pq.dll) to your
workstation. (So be sure to NOT install this on your main PostgreSQL
server -- no telling what will happen when the Cygwin version of the
PostgreSQL server tries to run at the same time as the native Win32
version already on there.)

2) The latest "release" version of PostgreSQL for Cygwin is v7.4.5.
There is v8.x code available in CVS, but you'll have to compile it
yourself. I'm also planning on doing this too, but I haven't had the
time.

- Bill

Bill Bartlett
meridianEMR, Inc.
http://www.meridianemr.com/

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of
> Richard van den Berg
> Sent: Friday, November 04, 2005 5:51 AM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] Using native win32 psql.exe using
> alternative cygwin terminal
>
>
> I just installed postgresql 8.1-rc1 on a Windows 2003
> machine. Since I like psql a lot, and hate the cmd.exe
> terminal, I use puttycyg instead.
>
> When I tried using psql.exe in a puttycyg terminal, after
> entering my password for the database, the screen just
> "hangs". When I do the same from a cygwin cmd.exe terminal,
> everything works. Another detail: the password using cmd.exe
> is hidden, using puttycyg it is shown.
>
> The exact same behaviour is shown when using the OpenSSH daemon (under
> cygwin) and logging in to it from remote (putty client or
> OpenSSH client).
>
> It looks like there is a problem with the interactive mode.
> When I run:
>
> psql -d postgres -c 'select * from pg_tables limit 1;'
>
> the output is shown just fine. I tried different TERM
> settings, but they made no difference.
>
> Is there something I can do to make this combination work?
> I'd gladly do more tests..
>
> Sincerely,
>
> --
> Richard van den Berg, CISSP
> -------------------------------------------
> Trust Factory B.V. | www.dna-portal.net
> Bazarstraat 44a | www.trust-factory.com
> 2518AK The Hague | Phone: +31 70 3620684
> The Netherlands | Fax : +31 70 3603009
> -------------------------------------------
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org
> so that your
> message can get through to the mailing list cleanly
>


From: Reid Thompson <reid(dot)thompson(at)ateb(dot)com>
To: Bill Bartlett <bbartlett(at)meridianemr(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using native win32 psql.exe using alternative cygwin
Date: 2005-11-07 01:52:43
Message-ID: 436EB36B.905@ateb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Bill Bartlett wrote:

>I hit this exact same problem, and my initial reaction was the same as
>yours -- psql was "hanging". After much head-banging, I discovered that
>it is not in fact hanging, but is instead getting confused by being run
>from inside Putty, Cygwin, xterm, rxvt terminal, etc. Because psql is
>not being run from a native Win32 console window, it puts itself into
>non-interactive mode, so it shows no prompts, allows no line editing,
>shows no command history, etc. But it is actually running. (And I
>couldn't find any combination of TERM settings, security settings or any
>other settings that would get around this.)
>
>Unfortunately, at the moment there is no command-line flag to force psql
>into "interactive" mode. I have the code (courtesy of Bruce Momjian) to
>add a flag such as this, but I haven't had time to set up the
>environment to actually recompile psql.
>
>Alternatively, you can run Cygwin's version of psql against the native
>Win32 PostgreSQL 8 database, assuming you install the base Cygwin
>environment. This does work fine, and gives you the added benefit of
>including "readline" support (something compiled out of the native Win32
>version of psql), so tab-completion works even in the Windows
>environment. Two caveats, however:
>
>1) You can't install _just_ psql from the Cygwin setup -- you'll have to
>install the complete PostgreSQL environment (database and all), then
>copy just the psql-related files (psql.exe and pq.dll) to your
>workstation. (So be sure to NOT install this on your main PostgreSQL
>server -- no telling what will happen when the Cygwin version of the
>PostgreSQL server tries to run at the same time as the native Win32
>version already on there.)
>
>2) The latest "release" version of PostgreSQL for Cygwin is v7.4.5.
>There is v8.x code available in CVS, but you'll have to compile it
>yourself. I'm also planning on doing this too, but I haven't had the
>time.
>
>- Bill
>
>
>
as info -- if you use the cygwin setup program, and click the
Exp(erimental) tab, you'll get 8.0.0-cvs downloaded/installed.
You can check the box to download the source also/instead, if you want
to build yourself....


From: Richard van den Berg <richard(dot)vandenberg(at)trust-factory(dot)com>
To: Reid Thompson <reid(dot)thompson(at)ateb(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using native win32 psql.exe using alternative cygwin
Date: 2005-11-07 08:33:59
Message-ID: 436F1177.7050603@trust-factory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Reid Thompson wrote:
> ala http://www.cygwin.com/ml/cygwin/2003-03/msg01457.html perhaps...???

Yes, indeed. It seems like a generic problem with running native windows
appplications with buffered output under a cygwin terminal emulator.
It's good to know the root of the problem, so I can still use 'psql -f
foo.sql' safely.

Sincerely,

--
Richard van den Berg, CISSP
-------------------------------------------
Trust Factory B.V. | www.dna-portal.net
Bazarstraat 44a | www.trust-factory.com
2518AK The Hague | Phone: +31 70 3620684
The Netherlands | Fax : +31 70 3603009
-------------------------------------------


From: Richard van den Berg <richard(dot)vandenberg(at)trust-factory(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Using native win32 psql.exe using alternative cygwin
Date: 2005-11-07 08:38:24
Message-ID: 436F1280.8030809@trust-factory.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Bill Bartlett wrote:
> I hit this exact same problem, and my initial reaction was the same as
> yours -- psql was "hanging". After much head-banging, I discovered that
> it is not in fact hanging, but is instead getting confused by being run
> from inside Putty, Cygwin, xterm, rxvt terminal, etc. Because psql is
> not being run from a native Win32 console window, it puts itself into
> non-interactive mode, so it shows no prompts, allows no line editing,
> shows no command history, etc. But it is actually running.

Thanks for sharing this insight. Reid Thompson pointed me to
http://www.cygwin.com/ml/cygwin/2003-03/msg01457.html where the cause of
this problem is discussed. It's good to know I can still use 'psql -f
foo.sql' safely under these terminals.

> Alternatively, you can run Cygwin's version of psql against the native
> Win32 PostgreSQL 8 database, assuming you install the base Cygwin
> environment.

I don't like the idea of running a different version of the client and
server, but the thought did cross my mind. I think I'll stick with the
cmd.exe terminal instead (for the time being).

Sincerely,

--
Richard van den Berg, CISSP
-------------------------------------------
Trust Factory B.V. | www.dna-portal.net
Bazarstraat 44a | www.trust-factory.com
2518AK The Hague | Phone: +31 70 3620684
The Netherlands | Fax : +31 70 3603009
-------------------------------------------


From: "Bill Bartlett" <bbartlett(at)softwareanalytics(dot)com>
To: "'Reid Thompson'" <reid(dot)thompson(at)ateb(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using native win32 psql.exe using alternative cygwin - psql 8.0.0 beta 3 question
Date: 2005-11-11 13:49:54
Message-ID: 02c501c5e6c6$cd3ae7f0$3500a8c0@bartletthome.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

>
> Bill Bartlett wrote:
>
> >I hit this exact same problem, and my initial reaction was
> the same as
> >yours -- psql was "hanging". After much head-banging, I discovered
> >that it is not in fact hanging, but is instead getting confused by
> >being run from inside Putty, Cygwin, xterm, rxvt terminal, etc.
> >Because psql is not being run from a native Win32 console window, it
> >puts itself into non-interactive mode, so it shows no
> prompts, allows
> >no line editing, shows no command history, etc. But it is actually
> >running. (And I couldn't find any combination of TERM settings,
> >security settings or any other settings that would get around this.)
> >
> >Unfortunately, at the moment there is no command-line flag to force
> >psql into "interactive" mode. I have the code (courtesy of Bruce
> >Momjian) to add a flag such as this, but I haven't had time
> to set up
> >the environment to actually recompile psql.
> >
> >Alternatively, you can run Cygwin's version of psql against
> the native
> >Win32 PostgreSQL 8 database, assuming you install the base Cygwin
> >environment. This does work fine, and gives you the added
> benefit of
> >including "readline" support (something compiled out of the native
> >Win32 version of psql), so tab-completion works even in the Windows
> >environment. Two caveats, however:
> >
> >1) You can't install _just_ psql from the Cygwin setup --
> you'll have
> >to install the complete PostgreSQL environment (database and
> all), then
> >copy just the psql-related files (psql.exe and pq.dll) to your
> >workstation. (So be sure to NOT install this on your main PostgreSQL
> >server -- no telling what will happen when the Cygwin version of the
> >PostgreSQL server tries to run at the same time as the native Win32
> >version already on there.)
> >
> >2) The latest "release" version of PostgreSQL for Cygwin is v7.4.5.
> >There is v8.x code available in CVS, but you'll have to compile it
> >yourself. I'm also planning on doing this too, but I
> haven't had the
> >time.
> >
> >- Bill
> >
> >
> >
> as info -- if you use the cygwin setup program, and click the
> Exp(erimental) tab, you'll get 8.0.0-cvs
> downloaded/installed. You can check the box to download the
> source also/instead, if you want
> to build yourself....
>

I hadn't noticed this -- thanks much! (Apparently it is also possible
to keep clicking through on the "version" column in Cygwin's setup
program and setup will cycle through all the versions that it has
available, one of which is 8.0.0 Beta 3.)

One question: Not knowing the development history of psql, is there any
reason I should build the latest 8.0.x release version of psql vs simply
using this "8.0.0 Beta 3" version already supplied by Cygwin, assuming
that for the immediate future we are still staying with 8.0.4 servers?

Tip to anyone else who wants to use the Cygwin version of psql against a
Win32 native PostgreSQL server: you'll need to include "-h localhost" on
the command line in order to connect to the local server.

- Bill