我可以在Perl中设置一个telnet连接没有问题,刚刚发现了Curses,我想知道我是否可以一起使用这两个连接来从telnet会话中获取输出.
我可以使用下面的简单脚本在行,列的基础上查看STDOUT的内容:
use Curses;
my $win = new Curses;
$win->addstr(10, 10, 'foo');
$win->refresh;
my $thischar=$win->inch(10,10);
print "Char $thischar\n";
Run Code Online (Sandbox Code Playgroud)
使用下面我可以打开一个telnet连接并发送\ receive命令没有问题:
use net::telnet;
my $telnet = new Net::Telnet (Timeout => 9999,);
$telnet->open($ipaddress) or die "telnet open failed\n";
$telnet->login($user,$pass);
my $output = $telnet->cmd("command string");
Run Code Online (Sandbox Code Playgroud)
...但我真正想做的是获取telnet响应(包括终端控制字符),然后使用curses在行/列上搜索.有谁知道我可以将两者连接在一起的方式?在我看来,curses只能在STDOUT上运行