Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How is this possible?

NodeX# ping
PING (xx.yy.8.11) 56(84) bytes of data.
64 bytes from (xx.yy.8.11): icmp_seq=1 ttl=127 time=0.657 ms
NodeX# /usr/bin/ -uuser -ppasssword 
Transferring myftp.tgz to
*** ftp login failed: [Errno -5] No address associated with hostname
Operation failed, exit code=3

Whereas if I do this, it works:

NodeX# /usr/bin/ -fxx.yy.8.11 -uuser -ppassword 
Transferring myftp.tgz to
Operation completed successfully

Also, if I create an entry in /etc/hosts, then it works using the name. What gives?

Dig shows:

NodeX# dig ANY

; <<>> DiG 9.5.0-P2 <<>> ANY
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21125
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

; IN      ANY

;; ANSWER SECTION: 28800 IN A       xx.yy.8.11

;; Query time: 1 msec
;; SERVER: xx.zz.8.34#53(xx.zz.8.34)
;; WHEN: Thu Oct 11 14:53:00 2012
;; MSG SIZE  rcvd: 63

resolv.conf shows 2 nameservers, a dig @each returns the IP.

Python 2.6 code looks like:

        print("Preparing ftplib.FTP for " + ftpHost)
        ftp = ftplib.FTP()
    except Exception, e:
        print("*** ftp prep failed: %s" % e.__str__())
        return 3
        print("Connecting to '" + ftpHost + "'")
        ftp.connect(ftpHost, ftpPort)
    except Exception, e:
        print("*** ftp connection failed: %s" % e.__str__())
        return 4

Output is:

Preparing ftplib.FTP for
Connecting to ''
*** ftp connection failed: [Errno -5] No address associated with hostname
Operation failed, exit code=4


Node2414332# ping
PING (xx.yy.8.11) 56(84) bytes of data.
64 bytes from (xx.yy.8.11): icmp_seq=1 ttl=127 time=0.804 ms


Though our python’s createconnection() fails in getaddrinfo() when given a hostname (see below), it works with an address. Conveniently, gethostbyname() works and so we have the simple fix: createconnection(gethostbyname(hostname)). Weerd.

share|improve this question

migrated from Oct 11 '12 at 18:38

This question came from our site for professional and enthusiast programmers.

This may be a better question for – grieve Oct 11 '12 at 16:40
What does the output of "dig ANY" look like? – David K. Hess Oct 11 '12 at 16:41
Can that hostname be resolved via all the name servers in resolv.conf? (i'm assuming you're using Linux based on your prompt and pathing) Is the machine dual homed? – tMC Oct 11 '12 at 17:01
do you by any chance have a dash "-" in the hostname, that causes parsing of the line arguments to interpret them wrong? – Iliyan Bobev Oct 11 '12 at 17:02
@David, I've extended the question with dig output - thanks for having a go :) – DJC Oct 11 '12 at 22:39

You must log in to answer this question.

Browse other questions tagged .