Where can I find an example that uses FTP standard library?

Q

QuadriKev

I am fairly new to programming in Python. There are a number of cases
where I would like to see examples of programs written. I like to
write them on Windows and in some cases put them on my Linux server to
do something useful.

I am also interested in using Telnet to check services and things on
the Linux server. Can someone give me direction on the best place for
examples? Full example of something written with GTK or wxPython would
be very interesting also.

TIA
 
G

Grig Gheorghiu

I have some code that looks something like this:

from ftplib import FTP

ftp = FTP()
# connect and login
ftp.connect(server_name)
ftp.login(user_name, password)
cmd = "STOR %s" % filename
#"ASCII transfer"
l = open(filename)
ftp.storlines(cmd, l)
#"BIN transfer"
l = open(filename, 'rb')
ftp.storbinary(cmd, l)
# close connection
ftp.close()

All the various methods on the ftp object should be called in
try/except blocks, since they can potentially raise exceptions.

Grig
 
C

cosmo

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top