473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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

Nov 22 '05 #1
3 6269
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

Nov 22 '05 #2
Pick up a copy of the Python Cookbook, it is full of examples.

You also might want to check out this site:

http://aspn.activestate.com/ASPN/Cookbook/Python

It contains 100's of code samples that might help.

The archives of this list are also a good place to look.
Google is also your friend. I entered python ftplib example
and turned up several examples like:

http://postneo.com/stories/2003/01/0...ibExample.html

-Larry Bates

QuadriKev wrote:
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

Nov 22 '05 #3

QuadriKev wrote:
I would like to see examples of programs written.
http://python.codefetch.com lets you search published books for Python
example source code.
I am also interested in using Telnet to check services and things on
the Linux server.


a search for "telnet" on codefetch brought up this nice example source
code:

http://www.codefetch.com/cache?url=h...thon&qy=telnet

from the book _Python Cookbook_

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Raymond Hettinger | last post by:
Comments are invited on the following proposed PEP. Raymond Hettinger ------------------------------------------------------- PEP: 329
25
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
2
by: Simon Elliott | last post by:
For new C++ code which uses the C standard library, there's a new convention for includes, for example, <stdio.h> becomes <cstdio>. What happens with some of the more obscure headers such as...
5
by: funkyj | last post by:
I love pexpect because it means I may never have to use expect again (I don't do any heavy expect lifting -- I just need simple tty control)! As a python advocate I find it embarassing how...
6
by: Frederick Gotham | last post by:
I gather that, rather than the C++ Standard defining the functionality of the Standard Library features which it has in common with C, it makes reference to a C Standard which defines their...
7
by: Francine.Neary | last post by:
This may well be implementation-defined or undefined behavior... if so, then of course that's a good enough answer. Consider the following situation: /* file1.c */ int (*f)(const char *,...
31
by: Francine.Neary | last post by:
One interesting thing to come out of the recent "Alignment" thread is that it is impossible to write a portable replacement for malloc in "user space" (not sure what the right term is - I mean an...
16
by: subramanian100in | last post by:
Program 1: --------------- #include <cstdlib> #include <iostream> #include <vector> using namespace std; int main() {
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.