FTP program works -- now how do I send the directory over?

Kemp Randy-W18971 Randy.L.Kemp at motorola.com
Thu Jul 5 09:54:36 EDT 2001


I seem to be getting the listing of what's on my d drive in windows, rather then the binary contents.  Here is what I do (the server id changed to protect the innocent:

------------------------> Step 1 <----------------------------------------------
Execute this program in Windoze

import string, os
import ftplib
import glob
filename = os.path.join("d:", "programsPython", "outdata3.txt")
listname = string.join(os.listdir('d:\programsPython'),',')
print listname
ftp = ftplib.FTP('144.144.144.144') #specify host
ftp.connect() # defaults to port 21, check docs for further options
ftp.login(user=goofy',passwd='elmer',acct='fudd)   # user info
ftp.cwd('/usr2/ecadtesting/tarbackups')
for filename in glob.glob('d:\programsPython\*'):
    ftp.storbinary("STOR " + filename, open(filename, 'rb'))
ftp.retrlines('LIST')  # list directory contents
ftp.quit()

-----------------> Step 2 <-----------------------------------------------
List the directory contents in Unix

ee110:/usr2/ecadtesting/tarbackups> ls
d:\programsPython\CE H2-102000 Usage Mentor1.txt
d:\programsPython\Db_py.py
d:\programsPython\IndataMentor.txt
d:\programsPython\RKListPython.py
d:\programsPython\RKListPython.py.bak
d:\programsPython\debug_bat
d:\programsPython\ftpdata.py
d:\programsPython\ftpdata.py.bak
d:\programsPython\indata.txt
d:\programsPython\indata.txt.bak
d:\programsPython\outdata.Final.txt
d:\programsPython\outdata.txt
d:\programsPython\outdata3.txt
d:\programsPython\output3.txt
d:\programsPython\rkparse.py
d:\programsPython\rkparse.py.bak
d:\programsPython\rkparse1.py
d:\programsPython\rkparse1.py.bak
d:\programsPython\rkparsemetrics.py
d:\programsPython\rkparsemetrics.py.bak
d:\programsPython\test.pdf
d:\programsPython\test.txt
d:\programsPython\testmail.py
ee110:/usr2/ecadtesting/tarbackups> 

-----------------> Problem <--------------------------------------
Why do I get the text d:\programsPython\filename?
How should I change the program to get the actual files sent over?









More information about the Python-list mailing list