telnet内联perl?

Raz*_*orm 1 perl telnet

有没有办法允许perl启动telnet会话并以编程方式向该telnet会话发出命令?

我最初尝试了一种愚蠢的方法:

commands.pl:

sleep(1);
print $command1;
sleep(1);
print $command2;
Run Code Online (Sandbox Code Playgroud)

然后

> perl commands.pl | telnet www.host.com port
Run Code Online (Sandbox Code Playgroud)

这不起作用.

bre*_*nie 8

有一个Net :: Telnet模块.

use Net::Telnet ();
$t = new Net::Telnet (Timeout => 10,
                      Prompt => '/bash\$ $/');
$t->open("sparky");
$t->login($username, $passwd);
@lines = $t->cmd("who");
print @lines;
Run Code Online (Sandbox Code Playgroud)

(从该页面获取的示例.)