我正在尝试从 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.
您必须安装 sh open key 才能无需密码即可访问 X.X.X.X。
$ ssh-keygen
$ ssh-copy-id -i ~/.ssh/id_rsa.pub X.X.X.X
您可以尝试使用 ssh 访问主机:
$ ssh X.X.X.X
请添加类似的内容
local *FILE;
在文件的开头删除这些关于裸字的警告。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)