Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by alexpapa (Initiate)
on Nov 16, 2010 at 17:42 UTC ( [id://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 ftpOut.pl 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); }
thanks!

Replies are listed 'Best First'.
Re: NET::SFTP - Permission Denied (preserve timestamps?)
by salva (Canon) 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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://871786]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found