2012-06-21 4 views
1

우분투 컴퓨터에서 동일한 LAN에있는 원격 호스트 (우분투)의/root 디렉토리 아래에있는 파일 (temp.txt)을 읽으려고합니다 (ssh 및 ftp가 열려 있음) 펄 스크립트가 연결이 가능하고 OpenSSH 대화 상자가 나타나 암호를 물어 본 다음 프로그램이 존재합니다. 제발 아무도 도와 줄 수 없습니다. 내 스크립트는 다음과 같습니다.perl을 사용하여 원격 호스트에서 파일 읽기

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. 

답변

2

비밀 번호없이 X.X.X.X에 액세스하려면 sh 열림 키를 설치해야합니다. 당신은 ssh를 이용하여 호스트 액세스를 시도 할 수있는 것보다

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

: 파일의 시작 부분에

local *FILE; 

같이하십시오 뭔가를

$ ssh X.X.X.X 

을 그리고 추가 약이 경고 제거하기 bareword.