Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl SFTP do_mkdir not able to create directory

by salva (Abbot)
on Apr 05, 2013 at 07:30 UTC ( #1027087=note: print w/ replies, xml ) Need Help??


in reply to Perl SFTP do_mkdir not able to create directory

Use Net::SFTP::Foreign instead.

If you use it combined with Net::OpenSSH you will be even able to reuse the same SSH connections from all the threads:

use Net::OpenSSH; my $ssh = Net::OpenSSH->new($host, user => $InboundParameters[3], password => $InboundParameters[4]); # then from the threads call... sub sftp_task { my $sftp = $ssh->sftp; $sftp->mkdir("ftp2SAT5"); ... }


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 09, 2013 at 02:07 UTC
    Hi salva,

    Thanks for your response. But I am trying to send the file to different hosts. So I wont be able to use the same SSH to do the task I presume.

      In that case, you can use Net::OpenSSH::Parallel:
      use Net::OpenSSH::Parallel; my $pssh = Net::OpenSSH::Parallel->new; $pssh->add_host($_) for @hosts; sub sftp_task { my ($host, $ssh) = @_; my $sftp = $ssh->sftp; $sftp->mkdir("ftp2SAT5") or die "unable to create directory: " . $sftp->error; } $pssh->all(parsub => &sftp_task); $pssh->run;
        Fixed the issue by using fork as suggested by salva.

        Thank you PerlMonks

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (18)
As of 2015-07-30 18:46 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 (273 votes), past polls