Good Morning Monks, I have a couple of sftp related questions... first, because i couldn't get Net::SFTP installed correctly i went the system call route which is working for me,but i can't seem to capture the error from STDOUT when no file is found. This is preventing me from retrying when the error message is: "Couldn't stat remote file: No such file or directory" which i know i'm getting because it's in the STDOUT file after i run my code. I can't seem to check STDOUT for the message while it's still open. Is there a way to do this? A snippet of my code is as follows

open STDOUT,">$log" || die "Cannot open log forwriting.!"; open STDERR, ">&STDOUT" or die "Can't dup stdout"; @ret = `sftp $user\@$server <<EOF cd $srcdir $cmd $srcfile $tgtfile bye EOF`; while (<STDOUT>) { print "inside STDOUT and row is $_\n"; print "err is $_ ...retrying\n" if /No such file/; }

How can i check the STDOUT for the "No such file" error message that is in the STDOUT file?

Secondly, I'd prefer to use the Net::SFTP module. I believe it's a 3 step process where: 1) the target server needs my pub.key appended to it's authorized_keys file (which it does) 2) i need to install the Net-SSH-Perl-1.34.tar module. 3) i need to install the Net-SFTP-0.10.tar. Are these the 3 steps that need to occur? I'm having issues installing the module and getting it to work, so perhaps i'm missing a step or another dependent module? Any help would be greatly appreciated. thanks


In reply to Having trouble getting sftp to work by dirtdog

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.