This queue is for tickets about the TermReadKey CPAN distribution.

Report information
The Basics
Id:
16462
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
jns [...] gellyfish.co.uk
Requestors:
Christian.Huynh [...] telindus-arche.fr
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
2.30
Fixed in:
(no value)



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
Help on readkey error message (follow up)

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

Subject: Re: [cpan #16462] Help on readkey error message (follow up)
From: Jonathan Stowe <jns@gellyfish.com>
To: bug-TermReadKey@rt.cpan.org
Date: Tue, 13 Dec 2005 14:38:06 +0000
RT-Send-Cc:
On Tue, 2005-12-13 at 13:19, Christian Huynh wrote:
Show quoted text
> 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: >
Can you confirm if this is a native win32 SSH or the cygwin version? If the latter could you try this using the cygwin rather than the Activestate perl? Also you might want to try using the -t switch to ssh in order to force allocation of a pseudo TTY ( you may need to more than one like -tt) - I thgink part of the problem when using Activestate perl and a cygwin sshd is that you are not getting a windows console for the program to run in. Unfortunately I am not in a position to test this at the moment. /J\ -- This e-mail is sponsored by http://www.integration-house.com/
From: "Christian Huynh" <Christian.Huynh@telindus-arche.fr>
To: <jns@gellyfish.com>
Subject: RE: [cpan #16462] Help on readkey error message (follow up)
Date: Tue, 13 Dec 2005 14:42:00 +0000
RT-Send-Cc:
http://sshwindows.sourceforge.net/download/ I installed this ssh. It seems to be a cygwin version since i see the following processes when i start the service: cygrunsrv.exe 1652 AUTORITE NT\SYSTEM sshd.exe 2020 AUTORITE NT\SYSTEM Using "ssh -t" or "ssh -tt" (i tried up to -tttt) didnt work. I will try to download cygwin perl and test it. Thanks again for your help. Christian. -----Message d'origine----- De : Jonathan Stowe [mailto:jns@gellyfish.com] Envoyé : mardi 13 décembre 2005 15:12 À : Christian Huynh Cc : comment-TermReadKey@rt.cpan.org Objet : Re: Help on readkey error message (follow up) On Tue, 2005-12-13 at 13:19, Christian Huynh wrote:
Show quoted text
> 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: >
Can you confirm if this is a native win32 SSH or the cygwin version? If the latter could you try this using the cygwin rather than the Activestate perl? Also you might want to try using the -t switch to ssh in order to force allocation of a pseudo TTY ( you may need to more than one like -tt) - I thgink part of the problem when using Activestate perl and a cygwin sshd is that you are not getting a windows console for the program to run in. Unfortunately I am not in a position to test this at the moment. /J\ -- This e-mail is sponsored by http://www.integration-house.com/
Subject: RE: [cpan #16462] Help on readkey error message (follow up)
From: Jonathan Stowe <jns@gellyfish.com>
To: Christian.Huynh@telindus-arche.fr
CC: bug-TermReadKey@rt.cpan.org
Date: Tue, 13 Dec 2005 15:02:17 +0000
RT-Send-Cc:
On Tue, 2005-12-13 at 14:43, Christian Huynh via RT wrote:
Show quoted text
> http://sshwindows.sourceforge.net/download/ > > I installed this ssh. > > It seems to be a cygwin version since i see the following processes when i start the service: > > cygrunsrv.exe 1652 AUTORITE NT\SYSTEM > sshd.exe 2020 AUTORITE NT\SYSTEM > > Using "ssh -t" or "ssh -tt" (i tried up to -tttt) didnt work. > > I will try to download cygwin perl and test it. > > Thanks again for your help. >
Could you also check that you have the system environment variable CYGWIN set on the server and that it at least has "ntsec tty" in the value - you may have entered the value when you ran ssh-host-config initially. The 'tty' setting enables extra support for Unix like ttys but I am not sure whether this will force the allocation of terminals from sshd. /J\
Show quoted text
> Christian. > > -----Message d'origine----- > De : Jonathan Stowe [mailto:jns@gellyfish.com] > Envoyi : mardi 13 dicembre 2005 15:12 > @ : Christian Huynh > Cc : comment-TermReadKey@rt.cpan.org > Objet : Re: Help on readkey error message (follow up) > > On Tue, 2005-12-13 at 13:19, Christian Huynh wrote:
> > 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: > >
> > Can you confirm if this is a native win32 SSH or the cygwin version? If the latter could you try this using the cygwin rather than the Activestate perl? Also you might want to try using the -t switch to ssh in order to force allocation of a pseudo TTY ( you may need to more than one like -tt) - I thgink part of the problem when using Activestate perl and a cygwin sshd is that you are not getting a windows console for the program to run in. > > Unfortunately I am not in a position to test this at the moment. > > /J\
-- This e-mail is sponsored by http://www.integration-house.com/


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.