如何使用 Net::Telnet 模块在 Perl 中发送箭头键?
使用 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 中发送这些代码?这些代码与键盘上按下的箭头键相同吗?
Using the Perl module Net::Telnet, how do you send an arrow key to a telnet session so that it would be the same thing as a user pressing the down key on the keyboard?
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);
This list of VT102 codes says that cursor keycodes are the following:
Up: Esc [ A
033 133 101
Down: Esc [ B
033 133 102
Right: Esc [ C
033 133 103
Left: Esc [ D
033 133 104
How would I send these in telnet? Are these codes the same as an arrow key pressed at the keyboard?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试打印
"\e[B"
。这些代码确实是相同的 - 尝试在没有 readline 支持的情况下运行 Bourne shellsh
并点击向上/向下箭头,您会看到类似^[[A
的内容,其中 < code>^[ 表示转义字符。Try printing
"\e[B"
. These codes are indeed the same - try running the Bourne shellsh
without readline support and hit the up/down arrows, you'll see something like^[[A
where^[
represents the escape character.有些程序期望 SS3 逃逸,而不是 CSI。如果“\e[A”和朋友不起作用,请尝试:(
那些是大写字母 o,而不是零)
Some programs expect SS3 escapes, rather than CSI. If "\e[A" and friend don't work, try:
(those are upper case letter o's, not zeros)