| Posted on 2008-05-25 17:45:07-07 by ongaku |
| scp_get works on one site, not another... |
|
Hi,
I'm at my wits end here.
I'm trying to bring across some files automatically.
It works on one site, but not on the one that counts :-(
Here's the code:
#!perl -w
use strict;
use Net::SSH2;
#use IO::Scalar;
#use IO::Tokenized::Scalar; # I'm using Active Perl, they seem not to have this in archives
my $user;
my $pass;
my $host;
my $testfile;
if ($ARGV[0] ne 'esk') {
print "jabcap\n";
$user = 'xxxxxxxx';
$pass = 'xxxxxxxx';
$host = 'fts.jpmchase.com';
$testfile = 'fo_prior_day_position_summary.csv';
} else {
print "eskimo\n";
$user = 'xxxxxxxx';
$pass= 'xxxxxxxx';
$host = 'eskimo.com';
$testfile = 'aaa';
}
my $ssh2 = Net::SSH2->new;
$ssh2->debug(1);
die "can't connect" unless $ssh2->connect($host);
die "can't authenticate"
unless $ssh2->auth(username => $user, password=>$pass, interact => 1);
my $sftp = $ssh2->sftp;
my $dir = $sftp->opendir('.') or die;
while ( my $rfile = $dir->read()) {
if (($rfile->{mode} & 0170000) >> 15) { # Is this a file?
print "uid: $rfile->{uid}\n";
print "mode: $rfile->{mode}\n";
print "mtime: $rfile->{mtime}\n";
print "name: $rfile->{name}\n";
print "atime: $rfile->{atime}\n";
print "size: $rfile->{size}\n";
print "gid: $rfile->{gid}\n";
print "Type: File\n";
print "name:" . $rfile->{name} . "\n";
$ssh2->scp_get ($rfile->{name});
last;
}
}
sub _read {
my $handle = shift;
while (my $line = <$handle>) {
chomp $line;
print "read line: '$line'\n";
}
}
This one works:
eskimo
libssh2_sftp_init(ss->session) -> 0x1c6cf50
libssh2_sftp_open_ex(sf->sftp, (char*)pv_dir, len_dir, 0 , 0 , 1) -> 0x1aef450
hv_from_attrs: attrs->flags = 15
<several times above>
uid: 10225
mode: 33152
mtime: 1021637587
name: jalperl.tar # finds this file to download
atime: 1211738761
size: 61440
gid: 57
Type: File
name:jalperl.tar
gid: 57
Type: File
name:jalperl.tar
libssh2_scp_recv(ss->session, path, &st) -> 0x1d11958
Net::SSH2::Channel::read(size = 61440, ext = 0)
- read 61440 bytes
- read 61440 total
Net::SSH2::Channel::read(size = 1, ext = 0)
- read 1 bytes
- read 1 total
Net::SSH2::Channel::DESTROY
Net::SSH2::Dir::DESTROY
Net::SSH2::SFTP::DESTROY
Net::SSH2::SFTP::DESTROY freeing session
Net::SSH2::DESTROY object 0x1a5ea9c
This one finds the file, but can't bring it across:
[example] aperl jread.pl jab
jabcap
libssh2_sftp_init(ss->session) -> 0x18366d0
libssh2_sftp_open_ex(sf->sftp, (char*)pv_dir, len_dir, 0 , 0 , 1) -> 0x1aef4c0
hv_from_attrs: attrs->flags = 15
hv_from_attrs: attrs->flags = 15
hv_from_attrs: attrs->flags = 15
uid: 4000
mode: 33188
mtime: 1211605440
name: fo_prior_day_balances_by_currency.csv
# here's what we're going to bring down
atime: 1211605440
size: 1962
gid: 5000
Type: File
name:fo_prior_day_balances_by_currency.csv
libssh2_scp_recv(ss->session, path, &st) -> 0x0
0x0 ---> didn't get it
Net::SSH2::Dir::DESTROY
Net::SSH2::SFTP::DESTROY
Net::SSH2::SFTP::DESTROY freeing session
Net::SSH2::DESTROY object 0x1a5ea9c
Please, can anyone help?
--John |
| Direct Responses: Write a response |