Re: Net:SFTP Configuration
- From: kilarurajeev@xxxxxxxxx (Kilaru Rajeev)
- Date: Mon, 27 Aug 2007 17:38:26 +0530
Hi Chas,
I have written the program as follows:
use strict;
use Net::SFTP;
use Net::SFTP::Constants ':status';
my $user;
my($host) = "sacsun120";
# set up the arguments based on the command line options
my %args = (ssh_args => []);
$args{debug} = 1;
foreach (keys(%args)) {
print "$_ -> $args{$_}\n";
}
push @{ $args{ssh_args} }, user => "crdadm";
$args{"password"} = "crpr0cess";
# make our connection
print "Connecting to $host...\n";
foreach (keys(%args)) {
print "$_ -> $args{$_}\n";
}
my $sftp = Net::SFTP->new($host, %args);
# get a listing of the base directory
#$sftp->ls("." , sub { print $_[0]->{longname}, "\n" });
$sftp->get("/trading/tisissuer08260004.txt",".");
my ($status, $msg) = $sftp->status;
print "ERROR with get: $msg\n";
print "Finished\n";
When trying to copy the file, it is showing the following error eventhough
the file is there.
*ssh_args -> ARRAY(0xf096c)
debug -> 1
Connecting to sacsun120...
password -> crpr0cess
ssh_args -> ARRAY(0xf096c)
debug -> 1
in new of perl mod ..
cfg object :Net::SSH::Perl::Config=HASH(0x103fbc):
sacsun120: Reading configuration data /export/home/crdadm/.ssh/config
sacsun120: Reading configuration data /etc/ssh_config
sacsun120: Connecting to sacsun120, port 22.
sacsun120: Remote protocol version 2.0, remote software version
Sun_SSH_1.0.1
sacsun120: Net::SSH::Perl Version 1.28, protocol version 2.0.
sacsun120: No compat match: Sun_SSH_1.0.1.
sacsun120: Connection established.
sacsun120: Sent key-exchange init (KEXINIT), wait response.
sacsun120: Algorithms, c->s: 3des-cbc hmac-sha1 none
sacsun120: Algorithms, s->c: 3des-cbc hmac-sha1 none
sacsun120: Entering Diffie-Hellman Group 1 key exchange.
sacsun120: Sent DH public key, waiting for reply.
sacsun120: Received host key, type 'ssh-dss'.
sacsun120: Host 'sacsun120' is known and matches the host key.
sacsun120: Computing shared secret key.
sacsun120: Verifying server signature.
sacsun120: Waiting for NEWKEYS message.
sacsun120: Enabling incoming encryption/MAC/compression.
sacsun120: Send NEWKEYS, enable outgoing encryption/MAC/compression.
sacsun120: Sending request for user-authentication service.
sacsun120: Service accepted: ssh-userauth.
sacsun120: Trying empty user-authentication request.
sacsun120: Authentication methods that can continue: publickey,password.
sacsun120: Next method to try is publickey.
sacsun120: Trying pubkey authentication with key file
'/export/home/crdadm/.ssh/id_dsa'
sacsun120: Authentication methods that can continue: publickey,password.
sacsun120: Next method to try is publickey.
sacsun120: Next method to try is password.
sacsun120: Trying password authentication.
sacsun120: Login completed, opening dummy shell channel.
sacsun120: channel 0: new [client-session]
sacsun120: Requesting channel_open for channel 0.
sacsun120: channel 0: open confirm rwindow 0 rmax 16384
sacsun120: Got channel open confirmation, requesting shell.
sacsun120: Requesting service shell on channel 0.
sacsun120: channel 1: new [client-session]
sacsun120: Requesting channel_open for channel 1.
sacsun120: Sending subsystem: sftp
sacsun120: Requesting service subsystem on channel 1.
sacsun120: channel 1: open confirm rwindow 0 rmax 16384
sacsun120: sftp: Sending SSH2_FXP_INIT
sacsun120: sftp: Remote version: 2
sacsun120: sftp: Sent message T:17 I:0
sacsun120: sftp: Received stat reply T:101 I:0
Couldn't stat remote file: No such file or directory at sample.pl line 32
ERROR with get: No such file or directory
Finished
*
**I am not getting what it meant. Could you please helpme?
Thanks,
Rajeev Kilaru
On 8/24/07, kilaru rajeev <kilarurajeev@xxxxxxxxx > wrote:
Hi Chas,
It is perfect. Thanks a lot.
Regards,
Rajeev Kilaru
On 8/24/07, Chas Owens <chas.owens@xxxxxxxxx > wrote:
On 8/24/07, kilaru rajeev < kilarurajeev@xxxxxxxxx> wrote:
Hi Chas,why, it
I was not given the proper arguments to the *new* function. That is
was failed to connect. This time I have another trouble. As part of mycode,
I have used the below to statments to list the files in the directory.
files
my @ls = $sftp->ls("$srcDir/");
print "\n----------------->@ls\n";
But I am not getting the output eventhough the directory got some
except "------------------->" part. sometimes I am getting the outputas
below:HASH(0xd037e0)
---------------------> HASH(0xd03334) HASH(0xd033dc) HASH(0xd03498)
HASH(0xd03540) HASH(0xd035e8) HASH(0xd03690) HASH(0xd03738)
HASH(0xd044a4) HASH(0xd0454c) HASH(0xd045f4) HASH(0xd0469c)HASH(0xd04744)
HASH(0xd047ec) HASH(0xd05da0) HASH(0xd05dac) HASH(0xd05e24)HASH(0xd05e9c)
HASH(0xd05f50) HASH(0xd0601c) HASH(0xd060c4) HASH(0xd0616c)HASH(0xd06214)
HASH(0xd062bc) HASH(0xd06364) HASH(0xcdbc20) HASH(0xcdbcc8)HASH(0xcdbd70)
HASH(0xcdbe18) HASH(0xcdbec0) HASH(0xcdbf68)will
I am not sure about the return value of the $sftp->ls(). I thought it
return a list as in Net::FTP. How I should use it? Please help me.
from the docs:
$sftp->ls($remote [, $subref ])
Fetches a directory listing of $remote.
If $subref is specified, for each entry in the directory, $subref
will
be called and given a reference to a hash with three keys: filename,
the name of the entry in the directory listing; longname, an entry in
a "long" listing like ls -l; and a, a Net::SFTP::Attributes object,
which contains the file attributes of the entry (atime, mtime,
permissions, etc.).
If $subref is not specified, returns a list of directory entries,
each
of which is a reference to a hash as described in the previous
paragraph.
So if you only want the filenames you can say
my @ls = map { $_->{filename} } $sftp->ls($srcDir);
- Follow-Ups:
- Re: Net:SFTP Configuration
- From: Chas Owens
- Re: Net:SFTP Configuration
- References:
- Re: Net:SFTP Configuration
- From: Jeff Pang
- Re: Net:SFTP Configuration
- From: Kilaru Rajeev
- Re: Net:SFTP Configuration
- From: Chas Owens
- Re: Net:SFTP Configuration
- From: Kilaru Rajeev
- Re: Net:SFTP Configuration
- From: Chas Owens
- Re: Net:SFTP Configuration
- From: Kilaru Rajeev
- Re: Net:SFTP Configuration
- From: Chas Owens
- Re: Net:SFTP Configuration
- From: Kilaru Rajeev
- Re: Net:SFTP Configuration
- Prev by Date: Re: Longest prefix match
- Next by Date: Re: Longest prefix match
- Previous by thread: Re: Net:SFTP Configuration
- Next by thread: Re: Net:SFTP Configuration
- Index(es):
Relevant Pages
|
|