1

我正在尝试从 ubuntu 机器读取位于同一 LAN 中远程主机(ubuntu)上 /root 目录下的文件(temp.txt)。(ssh 和 ftp 已打开) perl 脚本能够连接并出现 OpenSSH 对话框要求密码,然后程序存在。请任何人帮助..以下是我的脚本。

use POSIX qw(strftime);
use strict;
use warnings;


use File::Remote;
 my $remote = new File::Remote;

# Standard filehandles
$remote->open(FILE, ">>X.X.X.X:/root/temp.txt") or die $!;
print FILE "Here's a line that's added.\n";
$remote->close(FILE);

执行时出现以下错误。

Bareword "FILE" not allowed while "strict subs" in use at /root/Desktop/test.pl line 10.
Bareword "FILE" not allowed while "strict subs" in use at /root/Desktop/test.pl line 12.
Execution of /root/Desktop/test.pl aborted due to compilation errors.
4

1 回答 1

2

您必须安装 sh open keys 才能在没有密码的情况下访问 XXXX。

$ ssh-keygen
$ ssh-copy-id -i ~/.ssh/id_rsa.pub X.X.X.X

您可以尝试使用 ssh 访问主机:

$ ssh X.X.X.X 

并请添加类似

local *FILE;

在文件的开头摆脱这些关于裸字的警告。

于 2012-06-21T09:54:51.107 回答