Thx for the hints.
Actually, I'm not appending, i'm simply "copying" (ie creating) the attachments to their own files on the remote system, but without creating a local copy first (inefficient).
I've tried this test prog:
$filename = "testfile.dat"; $payload = "qwertyuiop"; $args{user} = "xxx"; $args{password} = "yyy"; $host = "s.a.c.u"; $path = "/some/path/".$filename; print "connecting\n"; $sftp = Net::SFTP->new($host, %args); print "open\n"; $handle = $sftp->do_open($path, SSH2_FXF_WRITE | SSH2_FXF_CREAT); print "write\n"; $sftp->do_write($handle, 0, $payload); print "close\n"; $sftp->do_close($handle);
(where I've obscured the real values).
but it says

Permission denied at /usr/lib/perl5/site_perl/5.8.5/Net/SFTP.pm line 62

which is this line

$ssh->login($param{user}, $param{password});

I've tried replacing this with the hardcoded vals from my program and printed out the host value (looks ok), but same error.
FYI, I can successfully login manually from the cmd line using the same values(!), so I'm stuck...
Any ideas??
Cheers
Chris

In reply to Re^2: sftp->do_write howto? by chrism01
in thread sftp->do_write howto? by chrism01

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.