Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 18th, 2008, 10:35 PM
Jeff Schwab
Guest
 
Posts: n/a
Default ftp recursively

I need to move a directory tree (~9GB) from one machine to another on
the same LAN. What's the best (briefest and most portable) way to do
this in Python?

I see that urllib has some support for getting files by FTP, but that it
has some trouble distinguishing files from directories.

http://docs.python.org/lib/module-urllib.html

"The code handling the FTP protocol cannot differentiate
between a file and a directory."

I tried it anyway, but got an authentication problem. I don't see a
"how to log into the FTP server" section on docs.python.org. Is there a
tutorial I should read?

I am particularly looking for a quick, "good enough" solution that I can
use this afternoon. Thanks in advance to any kind-hearted soul who
chooses to help me out.
  #2  
Old March 18th, 2008, 10:55 PM
Paul Rubin
Guest
 
Posts: n/a
Default Re: ftp recursively

Jeff Schwab <jeff@schwabcenter.comwrites:
Quote:
I need to move a directory tree (~9GB) from one machine to another on
the same LAN. What's the best (briefest and most portable) way to do
this in Python?
os.popen("rsync ...")
  #3  
Old March 19th, 2008, 04:15 AM
Gabriel Genellina
Guest
 
Posts: n/a
Default Re: ftp recursively

En Tue, 18 Mar 2008 18:25:28 -0300, Jeff Schwab <jeff@schwabcenter.com>
escribió:
Quote:
I need to move a directory tree (~9GB) from one machine to another on
the same LAN. What's the best (briefest and most portable) way to do
this in Python?
See Tools/scripts/ftpmirror.py in your Python installation.

--
Gabriel Genellina

  #4  
Old March 19th, 2008, 05:05 AM
Jeff Schwab
Guest
 
Posts: n/a
Default Re: ftp recursively

Gabriel Genellina wrote:
Quote:
En Tue, 18 Mar 2008 18:25:28 -0300, Jeff Schwab <jeff@schwabcenter.com>
escribió:
>
Quote:
>I need to move a directory tree (~9GB) from one machine to another on
>the same LAN. What's the best (briefest and most portable) way to do
>this in Python?
>
See Tools/scripts/ftpmirror.py in your Python installation.
Thank you, that's perfect. Thanks to Arnaud as well, for the pointer to
ftplib, which might useful for other purposes as well.

Per the earlier advice of other posters (including one whose message
seems mysteriously to have disappeared from c.l.python), I just stuck
with the Unix tools I already knew: I ended up tarring the whole 9GB,
ftping it as a flat file, and untarring it on the other side. Of
course, the motivation wasn't just to get the files from point A to
point B using Unix (which I already know how to do), but to take
advantage of an opportunity to learn some Python; next time, I'll try
the ftpmirror.py script if it's generic enough, or ftplib if there are
more specific requirements.
  #5  
Old March 19th, 2008, 07:55 AM
Paul Rubin
Guest
 
Posts: n/a
Default Re: ftp recursively

Jeff Schwab <jeff@schwabcenter.comwrites:
Quote:
ftping it as a flat file, and untarring it on the other side. Of
course, the motivation wasn't just to get the files from point A to
point B using Unix (which I already know how to do), but to take
advantage of an opportunity to learn some Python; next time, I'll try
the ftpmirror.py script if it's generic enough, or ftplib if there are
more specific requirements.
I see, that wasn't clear in your original post. You should look at
the os.walk function if you want to know how to traverse a directory
tree (maybe you are already doing this). Also, for security reasons,
it's getting somewhat uncommon, and is generally not a good idea to
run an ftpd these days, even on a LAN. It's more usual these days
to transfer all files by rcp or rsync tunnelled through ssh.
  #6  
Old March 20th, 2008, 08:55 AM
Steven D'Aprano
Guest
 
Posts: n/a
Default Re: ftp recursively

On Wed, 19 Mar 2008 23:53:22 -0700, Jeff Schwab wrote:
Quote:
The point of rsync is to keep a local directory tree in sync with a
remote one, by transferring only change-sets that are conceptually
similar to patches. If you're only transferring files once, there's no
particular benefit (AFAIK) to using rsync rather than some kind of
recursive ftp.
Avoiding re-inventing the wheel is a big benefit.


--
Steven
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles