I would like to upload some of the files from a directory to another node.
i saved the target files into an array called @node2_files, opened a $sftp
connection and loop over the array content to send the files one by one.
Here is part of the codes:
------------------
use Cwd 'abs_path';
$currentpath = abs_path($ENV{'PWD'});
my %args = ("user", 'user', "password", 'passwd', "debug", '1');
my $host = 'node2';
my $sftp = Net::SFTP->new($host,%args);
for ($a=0; $a < scalar(@node2_files); $a++) {
my $localfile = $currentpath . "/". $node2_files[$a];
#my $remotefile = 'test';
my $remotefile = '/home/user/' . $node2_files[$a];
$sftp->put($localfile,$remotefile);
}
-----------
if i uncomment the line: #my $remotefile = 'test';
and comment the one right below,
it runs "fine": at least the files are uploaded correctly, and saved into
a new text file named test in /home/user/ - but of course i only get the
last file with name: test
but i really want to maintain the original file name.
So, if i use the uncommented line:
my $remotefile = '/home/user/' . $node2_files[$a];
i get:
master: Reading configuration data /home/chaos/.ssh/config
master: Reading configuration data /etc/ssh_config
master: Connecting to node2, port 22.
master: Remote protocol version 1.99, remote software version OpenSSH_3.5p1
master: Net::SSH::Perl Version 1.28, protocol version 2.0.
master: No compat match: OpenSSH_3.5p1.
master: Connection established.
master: Sent key-exchange init (KEXINIT), wait response.
master: Algorithms, c->s: 3des-cbc hmac-sha1 none
master: Algorithms, s->c: 3des-cbc hmac-sha1 none
master: Entering Diffie-Hellman Group 1 key exchange.
master: Sent DH public key, waiting for reply.
master: Received host key, type 'ssh-dss'.
master: Host 'node2' is known and matches the host key.
master: Computing shared secret key.
master: Verifying server signature.
master: Waiting for NEWKEYS message.
master: Enabling incoming encryption/MAC/compression.
master: Send NEWKEYS, enable outgoing encryption/MAC/compression.
master: Sending request for user-authentication service.
master: Service accepted: ssh-userauth.
master: Trying empty user-authentication request.
master: Authentication methods that can continue:
publickey,password,keyboard-interactive.
master: Next method to try is publickey.
master: Next method to try is password.
master: Trying password authentication.
master: Login completed, opening dummy shell channel.
master: channel 0: new [client-session]
master: Requesting channel_open for channel 0.
master: channel 0: open confirm rwindow 0 rmax 32768
master: Got channel open confirmation, requesting shell.
master: Requesting service shell on channel 0.
master: channel 1: new [client-session]
master: Requesting channel_open for channel 1.
master: Sending subsystem: sftp
master: Requesting service subsystem on channel 1.
master: channel 1: open confirm rwindow 0 rmax 32768
master: sftp: Sending SSH2_FXP_INIT
master: sftp: Remote version: 3
master: sftp: Sent SSH2_FXP_OPEN I:0 P:/home/user/epoch104.TXT
Wide character in subroutine entry at /usr/lib/perl5/vendor_perl/5.8.0/Digest/HMAC.pm line 59.
---------
Could anyone send sugestions to help me fix this problem?
Mahalo
rv,
|