From: | "Christian Huynh" <Christian.Huynh [...] telindus-arche.fr> |
To: | <jns [...] gellyfish.com> |
Subject: | Help on readkey error message (follow up) |
Date: | Tue, 13 Dec 2005 14:31:30 +0000 |
Hello! (sorry I sent incomplete message first)
What im trying to do is to connect to a W2K SP4 machine using openssh
(OpenSSH for Windows v3.8.1p1-1) and then run a perl script. This perl
script emulates a CLI (command line interpreter) and therefore uses
Term::ReadKey.
When running the script locally, i have no problem.
When running the script after login in using ssh, i get the following
message:
C:\Documents and Settings\pingouin>perl cli.pl
# GetConsoleMode failed, LastError=|6| at
d:/Perl/site/lib/Term/ReadKey.pm line 265.
I tried to debug the code and follow the code to:
$Id: ReadKey.pm,v 2.23 2005/01/11 21:16:31 jonathan Exp $
------------------------------------------------------------------------
---------------------------------------
265: elsif ( $_[0] =~ /^\d/ ) { SetReadMode( $_[0], $fh ) }
In readkey.XS:
------------------------------------------------------------------------
---------------------------------------
void ReadMode(PerlIO *file,int mode)
{
dTHR;
int handle;
int firsttime;
int oldmode;
struct tbuffer work;
struct tbuffer savebuf;
handle=PerlIO_fileno(file);
firsttime=!hv_exists(filehash, (char*)&handle, sizeof(int));
# ifdef WIN32
if (!GetConsoleMode((HANDLE)_get_osfhandle(handle), &work.Mode))
croak("GetConsoleMode failed,
LastError=|%d|",GetLastError());
According to microsoft, code 6 is
ERROR_INVALID_HANDLE 6 The handle is invalid.
To my understanding, ssh is using a terminal which looks invalid for
microsoft. Have you any information that could help me going further ?
Thanks for your help!
Christian Huynh
Perl version:
=========
This is perl, v5.8.7 built for MSWin32-x86-multi-thread
(with 14 registered patches, see perl -V for more detail)
Copyright 1987-2005, Larry Wall
Binary build 815 [211909] provided by ActiveState
http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Nov 2 2005 08:44:52
Cli.pl snippet code:
==============
use Term::ReadKey;
...
while (not $endrequest) {
ReadMode 4; # Turn off controls keys
while (not defined ($key = ReadKey(-1))) { ; }
ReadMode 0; # Reset tty mode before exiting