Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Function keys via Net::Telnet

by Dragonfly (Priest)
on Apr 04, 2001 at 09:25 UTC ( #69559=note: print w/ replies, xml ) Need Help??


in reply to Function keys via Net::Telnet

If you're logging into a Unix-type telnet server, you might need to send the terminal info to the command line so that it maps your function keys correctly.

This may even be as simple as setting your "TERM" environment variable to match the emulation mode of your terminal or terminal emulator. For example:

## Connect and login. use Net::Telnet (); $host = new Net::Telnet (Timeout => 30, Prompt => '/[%#>] $/'); $host->open($hostname); $host->login($username, $passwd); $host->cmd("export TERM=vt100");
After this you could try sending the ASCII function codes, perhaps, or whatever other techniques you were trying before.

Again, I'm not positive this will work for you as I've only used Net::Telnet on a couple of my scripts, but it's pretty easy, and might help you with the missing "functionality." ;-)


Comment on Re: Function keys via Net::Telnet
Download Code
(bbfu) (not unix) Re(2): Function keys via Net::Telnet
by bbfu (Curate) on Apr 04, 2001 at 09:57 UTC

    Ah, I guess I might've mentioned this... But it's VMS, not Unix. Actually, the reason I'm writing this script in the first place is that we are planning on moving over to an AIX box.

    Oh well, I get the feeling this is going to be a major pain to get working. I suppose it's not all that big a deal (the current scripts can't do function keys either), I just wanted to show the ALMIGHTY POWER OF PERL!!! *ahem* Er, sorry 'bout that. ;-)

    Anyway, thanks for trying to help out. Sorry I didn't give all the info to start...

    bbfu
    Seasons don't fear The Reaper.
    Nor do the wind, the sun, and the rain.
    We can be like they are.

      Net::Telnet won't negotiatiate terminal types, which is perhaps the problem. I suspect that VMS has mapped your terminal type to "dumb", which has no function key mappings.

      Try sending the VMS incantation "SET TERMINAL /DEVICE=VT200" right after you login, then the escape sequences should work. (From what I remember, the vt100 doesn't have F10..F12)

      The Net::Telnet docs mention an option_set method which isn't supported yet. Perhaps in a later rev, you can just let Net::Telnet send the terminal type.

        I had Net::Telnet execute a SHOW TERMINAL command and it came up with VT320 without my having done a SET TERMINAL but I decided to try it out anyway. It seems to be working now but I tried commenting out the SET TERMINAL command and it still works. =(

        Right now I'm sending "\e[18~" for F7. I swear I tried that last night and it didn't work. *sigh* Guess I should've used the dead chicken last night. =)

        The way I found what code to use (\e[18~ isn't documented anywhere on the 'net that I could find) deserves some mention... What I did was, using a telnet client that I knew worked in those menus, I logged into the VMS server and, from there, telneted into our development box running linux. The login prompt echo's back any control keys (including ^H, which is a pain) using ^[ to represent ESC. So I just started hitting function keys and recording what it echoed back. =)

        This is what I got back for all the function keys:

        F-Key String to Send ------------------------- F1 ^[OP F2 ^[OQ F3 ^[OR F4 ^[OS F5 ^[[16~ F6 ^[[17~ F7 ^[[18~ F8 ^[[19~ F9 ^[[20~ F10 ^[[21~ F11 ^[[23~ F12 ^[[24~

        Anyway, it now seems to be working. Thanks much for all your help! I never even thought to try the SET TERMINAL command. :-)

        bbfu
        Seasons don't fear The Reaper.
        Nor do the wind, the sun, and the rain.
        We can be like they are.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://69559]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-07-23 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (132 votes), past polls