Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] find files and put with ncftp
- Date: Thu, 8 Mar 2007 02:01:44 +0900
- From: "Nguyen Vu Hung" <vuhung16plus@??>
- Subject: Re: [tlug] find files and put with ncftp
- References: <78d7dd350703060754t1d13d297rb257db6629e5e9fb@example.com> <87slcidv2d.fsf@example.com>
On 3/7/07, Stephen J. Turnbull <stephen@??> wrote:Nguyen Vu Hung writes:
> Hi all, > > I wanted to find all files in a folder, then use ncftp to put the > file(s) to a remote ftp server. Here is the script:
rsync is a much happier way to do this if you can use [rs]sh (or have an rsync server available). If you must use FTP, curl knows how to upload (the -T option).
It is you who supporting me again :D
I have tried curl, my first test with it failed
aoclife:~/sbin# curl -T filename aoclife.mirror.list \ ftp://user:pass@??/public_html/tmp/filename curl: (9) Uploaded unaligned file size (0 out of 59 bytes)
So I gave up.
Then I tried python ( very first experience with it ). The code comes as follow:
#ftpu, ftpp, ftph: ftp username, password, hostname for eachfile in open('/root/filelist.test.txt', 'r'): putfile = open("\"" + eachfile.rstrip("\n") + "\"") conn = ftplib.FTP(ftph, "","") conn.login(user=ftpu, passwd=ftpp) conn.cwd('/public_html/tmp') conn.storbinary("STOR " + eachfile, eachfile) putfile.close() conn.close()
here, the file /root/filelist.test.txt' is the output of the find command, it contains list of files ( with spaces and some special charaters in file name ), like:
aoclife:~/sbin# head /root/filelist.test.txt /home/vuhung/public_html/aoc/aoclife.ddo.jp/recs/aoc-recs/L=Lawliet (2199) vs Andrew_LK (1977)- 25-2-2007 04`35`38.zip /home/vuhung/public_html/aoc/aoclife.ddo.jp/recs/aoc-recs/IamAbe 4v4 - 28-Feb-2007 20`05`08.zip /home/vuhung/public_html/aoc/aoclife.ddo.jp/recs/aoc-recs/FletcheR vs Exrtacy gg.rar
and when i ran the python scripts, it died with errors:
aoclife:~/sbin# ./putftp.py Traceback (most recent call last): File "./putftp.py", line 10, in ? putfile = open(eachfile.rstrip("\n")) IOError: [Errno 2] No such file or directory: '/home/vuhung/public_html/aoc/aoclife.ddo.jp/recs/aoc-recs/L=Lawliet (2199) vs Andrew_LK (1977)- 25-2-2007 04`35`38.zip'
FYI, I observed '=' and ' ' in the filename
#python 2.4ish #next time, I will debug my script under a normal user :D
-- Best Regards, Nguyen Hung Vu vuhung16plus{remove}@?? VIQR Standard: http://vi.i18n.kde.org/viqr http://www.flickr.com/photos/vuhung/tags/fav/
- References:
- [tlug] find files and put with ncftp
- From: Nguyen Vu Hung
- [tlug] find files and put with ncftp
- From: Stephen J. Turnbull
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] (OT) Reverse DNS resolution blues- ISP recommendations?
- Next by Date: Re: [tlug] find files and put with ncftp
- Previous by thread: Re: [tlug] find files and put with ncftp
- Next by thread: Re: [tlug] find files and put with ncftp
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links