Hi – I just ported a perl script that uses Net-SFTP, over to another box that did not have Net-SFTP installed. After struggling with the dependencies, I installed Net-SFTP-Foreign-1.77 and IO-Tty-1.12 and modified my script. It runs now (and I'm delighted by how compatible all the methods are).

Is there a known issue with Net-SFTP-Foreign not reading the /etc/hosts file, to resolve host names? I have this line of code in my script:

my $sftp = Net::SFTP::Foreign->new(user => $remote_user, host => $remote_host, password => $remote_pswd);

When variable $remote_host is set to the FQDN remote.server.com, script throws this error:

ssh: remote.server.com : Name or service not known

But when the variable is set to the actual IP address, works fine.

I can sftp to remote.server.com (using FQDN) from the Linux command line, and it works fine. (I actually don't even need a hosts file entry to get there – the FQDN is resolved by normal resolution process.) I only see the issue in the script. Is this known behavior? Any parameter I have to set, to help it resolve?

Perl 5.8.8 running on RHEL5.

Thanks,

Jim

In reply to Net-SFTP-Foreign not reading /etc/hosts file? by JimZipCode

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.