Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Perl SFTP do_mkdir not able to create directory

by Loops (Curate)
on Apr 05, 2013 at 06:37 UTC ( #1027076=note: print w/ replies, xml ) Need Help??


in reply to Perl SFTP do_mkdir not able to create directory

Seems you have to supply the attrs parameter to make do_mkdir happy. Also it returns 0 as a successful return, so "or die ..." will do the wrong thing unfortunately. Your code with a few modifications works okay:

use strict; use warnings; use Net::SFTP; use Net::SFTP::Attributes; sub sub1 { my @InboundParameters = @_; my $num = $InboundParameters[0]; print "started thread $num : Establishing connection with $Inbound +Parameters[1]\n"; my $host = $InboundParameters[2]; my $sftp = Net::SFTP->new($host, user => $InboundParameters[3], pa +ssword => $InboundParameters[4], debug => 0) or return ( { 'errors' => "Unable to connect to $h +ost: " . $@, 'success' => 0 } ); my $attrs = Net::SFTP::Attributes->new(()); $sftp->do_mkdir("ftp2SAT5", $attrs) and die; print "done with thread $num\n"; return $num; } sub1 qw(1 me localhost my_username my_password);


Comment on Re: Perl SFTP do_mkdir not able to create directory
Download Code
Replies are listed 'Best First'.
Re^2: Perl SFTP do_mkdir not able to create directory
by skylinedreamer (Novice) on Apr 05, 2013 at 09:33 UTC
    Hi Loops, thank you for your solution. It worked right out of the box. Seems like do_mkdir needs the Attributes to be included as the parameter

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027076]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2015-07-31 10:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls