[NEWBIE] ftplib error?
Steve Holden
sholden at holdenweb.com
Wed Jan 16 08:42:26 EST 2002
"Bruce Dykes" <bkd at graphnet.com> wrote in message
news:mailman.1011181284.886.python-list at python.org...
> Here's my code:
>
> import ftplib
> hostname = ftplib.FTP("192.168.13.21")
> hostname.login("joeuser","mydogsname")
> hostname.cwd("$SYSTEM.DATA") # see below
> hostname_numbers = hostname.retrlines("GET ALARMDATA")
> hostname.quit()
> print hostname_numbers
>
> # No, really. I'm calling an ftp server on a Tandem, and that's exactly
how
> 'cd' works in a regular interactive ftp session
>
> I'm running Python 2.1 on NT 4. My code above looks amazingly similar to
all
> the ftplib examples I've seen, except that I'm using 'hostname' instead of
> 'f' (which *can't* matter...can it?), and I'm using an IP address instead
of
> a name.
>
> Here's my traceback:
>
> Traceback (most recent call last):
> File "C:\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301,
in
> RunScript
> exec codeObject in __main__.__dict__
> File "C:\telex\ftp_test.py", line 2, in ?
> hostname = ftplib.FTP("192.168.13.21")
> File "c:\python21\lib\ftplib.py", line 108, in __init__
> self.connect(host)
> File "c:\python21\lib\ftplib.py", line 118, in connect
> self.sock.connect((self.host, self.port))
> File "<string>", line 1, in connect
> error: (10061, 'Connection refused')
>
> Is this an authentication failure? That shouldn't be happening because the
> interactive ftp session works just fine. Does ftplib not understand that
an
> IP address is equivalent to a name? That shouldn't be happening either.
>
> What's going on here?
Don't want to seem simple-minded, but does your interactive FTP client work
from the same machine you are running the Python script on? The error
message seems pretty unequivocal: the FTP server isn't prepared to accept
your request.
Given that you're using private IP addresses, maybe there's a firewall
component between your machine and the server that's rejectong your FTP
connection?
Otherwise, replace your host address with some known-accessible public host
and see what gives.
regards
Steve
--
http://www.holdenweb.com/
More information about the Python-list
mailing list