Pergunta

I am trying to read a file(temp.txt) placed under /root directory on remote host(ubuntu) in same LAN from ubuntu machine.(ssh and ftp are open) The perl script is able to connect and a OpenSSH dialog box appears asking for password and then program exists.Please anybody helps..below is my script.

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);

i get the below error when executed.

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.
Foi útil?

Solução

You must install sh open keys to be able to access X.X.X.X without a password.

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

Than you can try to access the host with ssh:

$ ssh X.X.X.X 

And add please something like

local *FILE;

at the beginning of the file to get rid of these warnings about bareword.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top