bbfu has asked for the wisdom of the Perl Monks concerning the following question:

I'm not sure if this is totally a Perl question but crazyinsomniac said I should post it.

I have a script that uses Net::Telnet to log into a server and execute an application. I've got it all working except that a few of the application's menus require function keys (eg: F7, F10, etc). I cannot seem to figure out how to send function keys over the telnet session.

I figured that it must be either an ANSI or ASCII special sequence that I need to send but I can't get it to work.

I've found this link, which contains some info about function keys as ASCII special sequences. This page has info about function keys as ANSI special sequences. Neither of these seem to be what I need, as nothing I do works. =(

If someone can give me a clue as to why it's not working, or point me in the direction of further information, I would much appreciate it.

I'm hoping that someone has handled this sort of thing before and can help me. I can probably manage to get along without using the function key items but it will limit what the script is able to do.

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

Replies are listed 'Best First'.
Re: Function keys via Net::Telnet
by Dragonfly (Priest) on Apr 04, 2001 at 09:25 UTC
    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." ;-)

      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.