Q1) This isn't a perl problem, it's a permissions problem.

This perl script lacks permission. Getting it done on the command line looks like this:

$ ssh fred@164.90.158.33 fred@fourth:/var/www/html$ cd pm_image/ fred@fourth:/var/www/html/pm_image$ mkdir larry fred@fourth:/var/www/html/pm_image$ ll total 12 drwxr-xr-x 3 fred fred 4096 Oct 16 18:04 ./ drwxr-xr-x 7 root root 4096 Oct 8 00:04 ../ drwxrwxr-x 2 fred fred 4096 Oct 16 18:04 larry/ fred@fourth:/var/www/html/pm_image$

fred is part of the sudo group, if it matters:

fred@fourth:~$ groups fred fred : fred sudo fred@fourth:~$

I thought I might find something here: Perl SFTP do_mkdir not able to create directory. Is this maybe where I need to be grubbing? Net::SFTP::Foreign::Attributes

I added the password back into the Config file. It gets populated by get_tiny like so:

sub get_tiny { use 5.011; use warnings; use Net::SFTP::Foreign; use Config::Tiny; use Data::Dumper; my $ini_path = qw( /home/hogan/Documents/html_template_data/6.values +.ini ); say "ini path is $ini_path"; my $sub_hash = "my_sftp"; my $Config = Config::Tiny->new; $Config = Config::Tiny->read( $ini_path, 'utf8' ); say Dumper $Config; # -> is optional between brackets my $domain = $Config->{$sub_hash}{'domain'}; my $username = $Config->{$sub_hash}{'username'}; my $password = $Config->{$sub_hash}{'password'}; my $port = $Config->{$sub_hash}{'port'}; #dial up the server say "values are $domain $username $port"; my $sftp = Net::SFTP::Foreign->new( $domain, more => '-v', user => $username, port => $port, password => $password ) or die "Can't connect: $!\n"; return $sftp; }

Doesn't help me out:

server dir is /var/www/html/perlmonks parameter array is /var/www/html/perlmonks Net::SFTP::Foreign=HASH(0x5 +6550258f450) SSH slave exited unexpectedly with error code 255

Do I have to wrap something like this?

$ scp -pr /source/directory user@host:the/target/directory

In reply to Re^2: modernizing a perl util to upload a file through sftp by Aldebaran
in thread modernizing a perl util to upload a file through sftp by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.