FTP program works -- now how do I send the directory over?
Kemp Randy-W18971
Randy.L.Kemp at motorola.com
Thu Jul 5 11:33:21 EDT 2001
I made the change and everything is working fine now. Thanks to everyone
for the wonderful support. And Python has another edge over Perl. With
Python, the FTP client is build in, while with Perl, you need to obtain and
install the CPAN (crummy programming archive network) libnet module.
-----Original Message-----
From: Oleg Broytmann [mailto:phd at phd.fep.ru]
Sent: Thursday, July 05, 2001 9:08 AM
To: Kemp Randy-W18971
Cc: 'python-list at python.org'
Subject: Re: FTP program works -- now how do I send the directory over?
On Thu, 5 Jul 2001, Kemp Randy-W18971 wrote:
> 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:
>
> for filename in glob.glob('d:\programsPython\*'):
> ftp.storbinary("STOR " + filename, open(filename, 'rb'))
> List the directory contents in Unix
>
> ee110:/usr2/ecadtesting/tarbackups> ls
> d:\programsPython\CE H2-102000 Usage Mentor1.txt
> Why do I get the text d:\programsPython\filename?
Because glob() returns full path, so you end up running commands like
ftp.storbinary("STOR " + 'd:\\programsPython\\CE H2-102000 Usage
Mentor1.txt'...
(please note double backslashes)
If you want just filenames without path you can do one of two things:
1) cd d:\programsPython (os.chdir("d:\\programsPython")) and then use
glob('*') - this will list just the curent directory
2) or cut off the file/path yourself:
for filename in glob.glob('d:\programsPython\*'):
name = string.split(filename, '\\')[-1]
ftp.storbinary("STOR " + name, open(filename, 'rb'))
> How should I change the program to get the actual files sent over?
Why do you think those funny files are not real files? It is just UNIX
didn't interpreted backslashes! :) I am sure they are your real files! Test
it.
Oleg.
----
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list