Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027076]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2018-05-20 20:15 GMT
Find Nodes?
    Voting Booth?