Basic Python FTP Question

Bob Piton piton123 at yahoo.com
Wed Mar 8 02:35:03 CET 2006


I have just discovered how to do ftp with python, and have a question
about using macdef.

I can connect to the ftp site, using the .netrc file:

machine my.ftpsite.com
login myuserid
password mypass
macdef dload
cd maindir
get myfile


and the python command:

cmdline = "ftp my.ftpsite.com" % ()
os.system(cmdline)


but, once I connect, I would like to be able to enter more
commands to do whatever kind of ftp I want.

But the way it seems to work is that you can have a  macdef init
which will do the same thing every time you connect.

If the macdef is named anything else, such as 'dload' as in the example,
above, there doesn't seem to be any way to enter a python command to
execute it.

I would like to have in the .netrc:

macdef def1
commands

macdef def2
commands

macdef def3
commands

etc.

and then somehow be able to run macdef def1 or  macdef def2  etc.,
depending on what I am doing within the python script.

Or if it's not a matter of having the macdefs in the .netrc file, then I
would like to know how to set up the proper ftp commands in python.

I hope this makes sense. I have the feeling I am missing some obvious
thing.




More information about the Python-list mailing list