Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用perl创建SSH会话时出现问题_Perl - Fatal编程技术网

使用perl创建SSH会话时出现问题

使用perl创建SSH会话时出现问题,perl,Perl,我有上面使用perl进行ssh会话的脚本,但是有错误消息 “无法将服务名称'ssh'映射到端口号”。我正在使用Windows操作系统。请告诉我哪里错了。尝试将ssh添加到您的服务文件中。服务文件位于: use Net::SSH::Perl; my $ssh = Net::SSH::Perl->new('$host',22); $ssh->login('$user','$pass'); my $out = $ssh->cmd("show clock"); print $out;

我有上面使用perl进行ssh会话的脚本,但是有错误消息
“无法将服务名称'ssh'映射到端口号”。我正在使用Windows操作系统。请告诉我哪里错了。

尝试将ssh添加到您的服务文件中。服务文件位于:

use Net::SSH::Perl;
my $ssh = Net::SSH::Perl->new('$host',22);
$ssh->login('$user','$pass');
my $out = $ssh->cmd("show clock");
print $out;
要添加的行如下所示:

%SystemRoot%\system32\drivers\etc\services

你真的把变量放在单引号之间了吗?他们不会被翻译的。。。
ssh 22/tcp  # Secure Shell Login