Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

NET::SFTP - Permission Denied (preserve timestamps?)

by alexpapa (Initiate)
on Nov 16, 2010 at 17:42 UTC ( #871786=perlquestion: print w/replies, xml ) Need Help??
alexpapa has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone,
I have a question regarding Net::SFTP.
I am writing a script which will poll a directory on my side for files that need to be transferred to an SFTP server every 5 minutes. I have a configuration file that defines a number of directories, some are FTP servers while some are SFTP, plus some additional information, such as whether to create a new directory remotely etc...
All of that works fine, except for one client who is giving me problems.
Error is: Couldn't get handle: Permission denied at line 147
I have tried sending a file using winSCP and received a permission error there as well - the only way to remove this was to uncheck "preserve timestamps".
So my question is, is there anyway for me to do this using Net::SFTP ?
the script ends here
if (! ($ftp->put($location.$fileName)) ) { &Logs(":Error:","Could + not PUT file $fileName from $location to $ftpHost"); die &SendFailEmail("Error with transferring $fileName to $ftpHost",$no +tificationEmail); }
the connection is made here
my $host = $ftpHost; my %args = ( user => $userName, password => $password, debug => 'true', ssh_args => [port => 22], ); if (! ($ftp = Net::SFTP->new($host, %args)) ) { &Logs(":Error:","Could not log +in to FTP $location $ftpHost"); die &SendFailEmail("Error with + connecting to $ftpHost",$notificationEmail); }

Replies are listed 'Best First'.
Re: NET::SFTP - Permission Denied (preserve timestamps?)
by salva (Abbot) on Nov 17, 2010 at 08:54 UTC
    Try using Net::SFTP::Foreign instead. Its put method can be toll to not copy file attributes using the copy_perm and copy_time arguments:
    $sftp->put($src, $target, copy_perm => 0, copy_time => 0);

    update: are you using Windows? then, read also this thread: SFTP on Windows.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://871786]
Approved by Corion
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2018-01-20 22:02 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.