lftp は高機能な ftp クライアント。
http://lftp.yar.ru/
オフィシャルサイトの Feature list と Man page を読めば、ftp 関連でやりたいと思うことは lftp でたいてい実現できることがわかる。
Feature list http://lftp.yar.ru/features.html
Man page http://lftp.yar.ru/lftp-man.html
Feature list から、対応しているプロトコルを引用。他にもいろいろ書いてあった。
http://lftp.yar.ru/features.html
ミラーリング時のオプションも豊富だ。ローカルに存在しなくてミラー先にのみ存在するファイルを削除するかどうか指定できるし、ミラーリング対象ファイルを正規表現で絞り込んだり、タイムスタンプで比較して新しいファイルのみをミラーしたりと、かゆいところに手が届くような機能ばかりだ。
以下 man page から抜粋。
http://lftp.yar.ru/lftp-man.html
以下、そのうち試したい機能。
FTP over HTTP proxy support は、squid を http と ftp の proxy サーバとして使用している環境で有用だろう。IE や Mozilla などのブラウザからは proxy を使って ftp サイトにアクセスできるのに、windows の ffftp をはじめとする ftp クライアントでは proxy を利用できない、という現象がある。これは ffftp などが FTP over HTTP proxy に対応していないために起こる。lftp ならこれを解決できるようだ。
追記。FTP over HTTP proxy support によるプロキシ越えは 2004-05-11 で実際に試してみた。
- lftp オフィシャルサイト
LFTP - reliable ftp clienthttp://lftp.yar.ru/
オフィシャルサイトの Feature list と Man page を読めば、ftp 関連でやりたいと思うことは lftp でたいてい実現できることがわかる。
Feature list http://lftp.yar.ru/features.html
Man page http://lftp.yar.ru/lftp-man.html
Feature list から、対応しているプロトコルを引用。他にもいろいろ書いてあった。
http://lftp.yar.ru/features.html
* FTP and HTTP protocols support.
* FTP (e.g. TIS FWTK) proxy support.
* HTTP proxy support.
* FTP over HTTP proxy support (hftp).
* HTTPS and FTPS protocols support using OpenSSL library.
* Automatic OPIE/SKEY support in FTP protocol.
* FXP transfers support (between two FTP servers, bypassing client machine).
* FTP listings support: unix-style, NT, EPLF.
* Automatic reconnect and retry of an operation on retriable errors or timeout.
* IPv6 support in both FTP and HTTP.
* FISH protocol support. It uses ssh with no special program on server side.
* SFTP protocol v3 and v4 support.
* HTTP/1.1 keep-alive support.
* Experimental support for SRV DNS records.
* SOCKS support (configure option).
- インストール
lftp はたいていの Linux ディストリビューションに含まれているようで、最初からインストールされていることが多い。私の cygwin にはインストールしていなかったが、cygwin 用 lftp のパッケージが用意されていて、cygwin の公式インストーラからインストールできた。cygwin の setup.exe http://www.cygwin.com/setup.exe を起動して lftp を選ぶだけだ。- 私の lftp コマンド
ローカルのファイル群を infoseek に ftp ミラーリングアップロードしている。$ lftp -c "open ftp.isweb.infoseek.co.jp && user USER_NAME PASSWORD && lcd /home/hiroaki/public_html/log && cd / && mirror -R -I 2002* & mirror -R -I 2003* & mirror -R -I 2004* && mirror -R -i '^dat.*|^cat.*|^all.*|^cl.*|^i.*'"
- lftp の便利な機能1 ミラーリングアップロード とミラーリングダウンロード
要するにローカルとリモートのファイルを同期させる機能。普通の無料ホームページサービスは ftp くらいしかアップロードする方法がない。rsync が使えるなら rsync で良いけど、rsync を使える無料ホームページサービスは少ないだろう。ミラーリングが使えるとローカルで html の出来をチェックしさえすれば、同じものがサーバにも置かれることになるのでとても便利だ。ミラーリング時のオプションも豊富だ。ローカルに存在しなくてミラー先にのみ存在するファイルを削除するかどうか指定できるし、ミラーリング対象ファイルを正規表現で絞り込んだり、タイムスタンプで比較して新しいファイルのみをミラーしたりと、かゆいところに手が届くような機能ばかりだ。
以下 man page から抜粋。
http://lftp.yar.ru/lftp-man.html
mirror [OPTS] [source [target]]
Mirror specified source directory to local target directory.
If target directory ends with a slash, the source base name
is appended to target directory name. Source and/or target
can be URLs pointing to directories.
-c, --continue continue a mirror job if possible
-e, --delete delete files not present at remote site
--delete-first delete old files before transferring new ones
-s, --allow-suid set suid/sgid bits according to remote site
--allow-chown try to set owner and group on files
--ignore-time ignore time when deciding whether to download
--ignore-size ignore size when deciding whether to download
--only-missing download only missing files
-n, --only-newer download only newer files (-c won't work)
-r, --no-recursion don't go to subdirectories
-p, --no-perms don't set file permissions
--no-umask don't apply umask to file modes
-R, --reverse reverse mirror (put files)
-L, --dereference download symbolic links as files
-N, --newer-than=SPEC download only files newer than specified time
-P, --parallel[=N] download N files in parallel
--use-pget[-n=N] use pget to transfer every single file
-i RX, --include RX include matching files
-x RX, --exclude RX exclude matching files
-I GP, --include-glob GP include matching files
-X GP, --exclude-glob GP exclude matching files
-v, --verbose[=level] verbose operation
--log=FILE write lftp commands being executed to FILE
--script=FILE write lftp commands to FILE, but don't execute them
--just-print, --dry-run same as --script=-
--use-cache use cached directory listings
--Remove-source-files remove files after transfer (use with caution)
-a same as --allow-chown --allow-suid --no-umask
- lftp の便利な機能2 ミラーリング時の自動再試行
http://lftp.yar.ru/features.htmlAutomatic reconnect and retry of an operation on retriable errors or timeout.自動再試行は便利だ。致命的でないエラーの時とタイムアウトの時は自動でリトライする。つまり、回線やサーバの ftpd が不安定だったりするときは自動でリトライしてくれる。この機能は非常にうれしい。infoseek の ftpd は混雑時は不安定になりがちだが、自動リトライ機能のおかげで安心して ftp できる。自動再試行についても、再試行回数や再試行間隔などのオプションが用意されている。詳細は man page を参照。
- lftp の便利な機能3 スクリプトファイルによる自動実行
ftp セッション中に実行したいコマンドをあらかじめ記述しておき、それを lftp に渡せば実行してくれるというもの。2003-12-01 に書いた「ftp: ftp + tar + cron で自動ネットワーク・バックアップ」で利用している機能だ。cron と組み合わせると定型的な作業を自動化できる。- lftp の便利な機能4 ジョブ制御
シェルに似たジョブの制御ができる。コマンドの最後に & を付けるとバックグラウンド実行になる。私の lftp コマンドでも & を付けているが、どこまで効果があるかは不明。複数の ftp セッションを開いて並行にアップロードしているのかどうか確かめてはいない。あとで確認しよう。- 他にも機能がいっぱい
lftp はとにかく高機能。man もそれだけ長いが、読む価値はある。perl や ruby で独自に ftp クライアントを実装するよりも、lftp を使った方が早くて確実だ。以下、そのうち試したい機能。
FTP over HTTP proxy support (hftp).
`pget' to download a file using several connections.
FTP over HTTP proxy support は、squid を http と ftp の proxy サーバとして使用している環境で有用だろう。IE や Mozilla などのブラウザからは proxy を使って ftp サイトにアクセスできるのに、windows の ffftp をはじめとする ftp クライアントでは proxy を利用できない、という現象がある。これは ffftp などが FTP over HTTP proxy に対応していないために起こる。lftp ならこれを解決できるようだ。
追記。FTP over HTTP proxy support によるプロキシ越えは 2004-05-11 で実際に試してみた。
以上の内容はhttp://sonic64.com//2004-05-08.htmlより取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます
モバイルやる夫Viewer Ver0.14