Win32 python: odd behavior when run via ssh

G

Grant Edwards

When I ssh into a windows machine (running Cygwin sshd), I can
invoke python at the shell prompt (you have to use -i option
and I don't really understand why).

Once it's started there are couple rather odd behaviors:

1) readline support doesn't work.

2) you have call sys.exit() to exit (neither ctrl-D or ctrl-Z
work)

Number 2) I don't really care about, but 1) is pretty annoying.
 
R

Ross Ridge

Grant Edwards said:
When I ssh into a windows machine (running Cygwin sshd), I can
invoke python at the shell prompt (you have to use -i option
and I don't really understand why).

Once it's started there are couple rather odd behaviors:

1) readline support doesn't work.

My guess is either that Cygwin version of Python you invoked doesn't
think that stdin/stdout is attached to a tty (ie. the pseudo-terminal
that sshd should create), or you're using official Win32 "native" Python
distribution Python and it doesn't think stdin/stdout is attached to
a console.

If you're using the Cygwin version of Python than it's probably bug.
If you're using the offficial Win32 port of Python than you probably
want to use the Cygwin version because Win32 version doesn't support
readline anyways.

Ross Ridge
 
G

Grant Edwards

My guess is either that Cygwin version of Python you invoked doesn't
think that stdin/stdout is attached to a tty (ie. the pseudo-terminal
that sshd should create), or you're using official Win32 "native" Python
distribution Python and it doesn't think stdin/stdout is attached to
a console.

The latter. I guess I forgot to say I was running the normal
Win32 python.
If you're using the Cygwin version of Python than it's
probably bug. If you're using the offficial Win32 port of
Python than you probably want to use the Cygwin version
because Win32 version doesn't support readline anyways.

That's odd, because readline seems to work fine in a Windows
console (recalling previous lines and line editing).
 
G

Gabriel Genellina

En Fri, 01 Feb 2008 22:31:06 -0200, Ross Ridge
If you're using the offficial Win32 port of Python than you probably
want to use the Cygwin version because Win32 version doesn't support
readline anyways.

I don't understand the comment. Most of the readline functionality is
already present on Windows XP (command history, up/down arrows, edit entry
with left/right arrows, choose entry from list, autocompletion, separate
buffers for each program...). On earlier versions you only had to load
doskey.exe (or doskey.com) at startup, and the command had existed from
jurasic age... That Python on Windows doesn't support specifically the GNU
readline utility is irrelevant.
 
M

Martin v. Löwis

That's odd, because readline seems to work fine in a Windows
console (recalling previous lines and line editing).

That's an illusion. The Windows version of Python does not
support or use GNU readline at all. What you see is a feature
of the console window.

Regards,
Martin
 
G

Grant Edwards

En Fri, 01 Feb 2008 22:31:06 -0200, Ross Ridge


I don't understand the comment. Most of the readline
functionality is already present on Windows XP (command
history, up/down arrows, edit entry with left/right arrows,
choose entry from list, autocompletion, separate buffers for
each program...). On earlier versions you only had to load
doskey.exe (or doskey.com) at startup, and the command had
existed from jurasic age... That Python on Windows doesn't
support specifically the GNU readline utility is irrelevant.

Until you try to run Python inside something other than the
Windows console.
 
S

Steve Holden

Gabriel said:
En Fri, 01 Feb 2008 22:31:06 -0200, Ross Ridge


I don't understand the comment. Most of the readline functionality is
already present on Windows XP (command history, up/down arrows, edit entry
with left/right arrows, choose entry from list, autocompletion, separate
buffers for each program...). On earlier versions you only had to load
doskey.exe (or doskey.com) at startup, and the command had existed from
jurasic age... That Python on Windows doesn't support specifically the GNU
readline utility is irrelevant.
Until you try to do something like a reverse history search using
CTRL/R, for example, and then the limitations of the XP command window
start to become obvious.

But it's somewhat perverse to try to run standard Windows binaries under
Cygwin. Though it is a fine environment you get into real trouble with
things like filename completion, since the shell completes names in the
Cygwin filename space, and the Windows binaries can't make head nor tail
of something like /c/Python25/python.exe.

That may well be why the Python interpreter isn't recognizing the sshd's
pty as a terminal, too.

regards
Steve
 
S

Steve Holden

Gabriel said:
En Fri, 01 Feb 2008 22:31:06 -0200, Ross Ridge


I don't understand the comment. Most of the readline functionality is
already present on Windows XP (command history, up/down arrows, edit entry
with left/right arrows, choose entry from list, autocompletion, separate
buffers for each program...). On earlier versions you only had to load
doskey.exe (or doskey.com) at startup, and the command had existed from
jurasic age... That Python on Windows doesn't support specifically the GNU
readline utility is irrelevant.
Until you try to do something like a reverse history search using
CTRL/R, for example, and then the limitations of the XP command window
start to become obvious.

But it's somewhat perverse to try to run standard Windows binaries under
Cygwin. Though it is a fine environment you get into real trouble with
things like filename completion, since the shell completes names in the
Cygwin filename space, and the Windows binaries can't make head nor tail
of something like /c/Python25/python.exe.

That may well be why the Python interpreter isn't recognizing the sshd's
pty as a terminal, too.

regards
Steve
 
G

Gabriel Genellina

Gabriel Genellina wrote:
I don't understand the comment. Most of the readline functionality is
already present on Windows XP (command history, up/down arrows, edit
[...]
Until you try to do something like a reverse history search using
CTRL/R, for example, and then the limitations of the XP command window
start to become obvious.

Just type a few characters, press F8 and see what happens.

(readline has a lot of features, and the Windows history editing
capabilities are somewhat limited, but it's amazing you choose exactly one
feature that IS implemented!)
 
T

Thorsten Kampe

* Gabriel Genellina (Fri, 01 Feb 2008 23:13:27 -0200)
En Fri, 01 Feb 2008 22:31:06 -0200, Ross Ridge


I don't understand the comment. Most of the readline functionality
is already present on Windows XP (command history, up/down arrows,
edit entry with left/right arrows, choose entry from list,
autocompletion, separate buffers for each program...).

Not at all readline compares to Cmd editing like Python to BASIC. If
in doubt, read the readline manpage.

Thorsten
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top