3

使用 Perl 模块 Net::Telnet,如何将箭头键发送到 telnet 会话,以便与用户按下键盘上的向下键相同?

use Net::Telnet;
my $t = new Net::Telnet();
my $down_key=?; #How do you send a down key in a telnet session?
t->print($down_key);

VT102 代码列表表明光标键代码如下:

Up:    Esc [   A
       033 133 101
Down:  Esc [   B
       033 133 102
Right: Esc [   C
       033 133 103
Left:  Esc [   D
       033 133 104

我将如何在 telnet 中发送这些?这些代码是否与在键盘上按下的箭头键相同?

4

2 回答 2

5

尝试打印"\e[B"。这些代码确实是相同的 - 尝试在sh没有 readline 支持的情况下运行 Bourne shell 并点击向上/向下箭头,您会看到类似^[[Awhere^[表示转义字符的内容。

于 2010-03-23T17:51:26.197 回答
1

一些程序期望 SS3 逃逸,而不是 CSI。如果 "\e[A" 和朋友不起作用,请尝试:

%ss3 = (
   up    => "\eOA",
   down  => "\eOB",
   right => "\eOC",
   left  => "\eOD",
);

(这些是大写字母 o,而不是零)

于 2010-03-24T01:30:13.290 回答