如何使用Net :: Telnet模块在Perl中发送箭头键? [英] How do I send an arrow key in Perl using the Net::Telnet module?
问题描述
使用Perl模块Net :: Telnet,如何将一个箭头键发送到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);
这个 VT102代码列表说光标键码如下: p>
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
如何在telnet中发送这些?这些代码是否与键盘上按下的箭头键相同?
How would I send these in telnet? Are these codes the same as an arrow key pressed at the keyboard?
推荐答案
尝试打印\ E [B
。这些代码确实是一样的 - 尝试运行Bourne shell sh
而不需要readline支持,并按下向上/向下箭头,你会看到类似于 ^ [[A
其中 ^ [
表示转义字符。
Try printing "\e[B"
. These codes are indeed the same - try running the Bourne shell sh
without readline support and hit the up/down arrows, you'll see something like ^[[A
where ^[
represents the escape character.
这篇关于如何使用Net :: Telnet模块在Perl中发送箭头键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!