Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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);

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 avoiding work at the Monastery: (7)
As of 2016-10-01 23:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (9 votes). Check out past polls.