[Ssh-sftp-perl-users] permission denied error
Brought to you by:
dbrobins
From: Curt S. <csh...@gm...> - 2006-02-27 15:31:25
|
I am trying to create a script that will get a document via sftp from a remote host. When I walk through the process manually everything is fine, but when I do the process via script I get Couldn't stat remote file: Permission denied at ./sftptest line 22 Below is the source for the script: ########Start Code############### #!/usr/bin/perl use strict; use Net::SFTP; use Net::SFTP::Util; use Net::SFTP::Constants; my $host = "testhost.test.com"; my $user = "username"; my $pass = "password"; my $port = "10022"; my $cmd = "get"; my $ldir = "/home/test"; my $rdir = "/"; my $localfile = 'username.test'; my $remotefile = 'username.test'; my $constatus = my $sftp = Net::SFTP->new("$host",user=>"$user",password=>"$pass",debug=>"1",ssh_args=> [port=>$port]); print "Connected!\n"; $sftp->$cmd("$rdir/$remotefile","$ldir/$localfile",\&callback); <- line 22 sub callback { my($sftp, $data, $offset, $size) = @_; print "Read $offset / $size bytes\r"; } ################End Code######################### If I change the $cmd to ls , this is successful but I cannot get the file. I have tried just "$remotefile","$localfile" (just for the record) rather than with the directory before it as well. Below is part of the debug file after connected: My.domain.name: Enabling incoming encryption/MAC/compression. My.domain.name: Send NEWKEYS, enable outgoing encryption/MAC/compression. My.domain.name: Sending request for user-authentication service. My.domain.name: Service accepted: ssh-userauth. My.domain.name: Trying empty user-authentication request. My.domain.name: Authentication methods that can continue: publickey,password,keyboard-interactive. My.domain.name: Next method to try is publickey. My.domain.name: Next method to try is password. My.domain.name: Trying password authentication. My.domain.name: Login completed, opening dummy shell channel. My.domain.name: channel 0: new [client-session] My.domain.name: Requesting channel_open for channel 0. My.domain.name: channel 0: open confirm rwindow 0 rmax 32768 My.domain.name: channel 1: new [client-session] My.domain.name: Requesting channel_open for channel 1. My.domain.name: Sending subsystem: sftp My.domain.name: Requesting service subsystem on channel 1. My.domain.name: channel 1: open confirm rwindow 0 rmax 32768 My.domain.name: sftp: Sending SSH2_FXP_INIT Mn.domain.name: sftp: Remote version: 3 My.domain.name: sftp: Sent message T:17 I:0 My.domain.name: sftp: Received stat reply T:101 I:0 Couldn't stat remote file: Permission denied at ./sftptest line 22 Any suggestions? Thanks Curt |