打印

lftp

lftp

8 `8 k4 Z. T$ e/ p* S: [4 g
lftp DebianWiki | RecentChanges | Preferences
  H9 X9 m: p. @2 R- @% |' o* I/ `2 K3 Y: z+ T" l
lftp支援SSL傳輸的FTP Clients
# w  x% r  ~' u9 V+ M指令名稱:lftp  C/ e9 R! `0 R
簡要功能說明:多才多藝的檔案傳輸工具。
+ F' ^2 ^2 x' t8 s詳細說明:lftp 支援了六種模式, ftp, ftps, http, https, hftp, fish and file (當然了 https 和 ftps 的支援必須在編譯就和 openssl library 一起編譯好)。lftp 內建了 shell-like 的命令格式, 允許在背景同時執行多個命令(&)。所有背景執行的工作都是在同一個程序中(process), 能將前景執行的命令放到背景執行(Ctrl-z), 或從背景拿回前景執行(wait 或 fg), 甚至還可以經由上個命令的傳回值來決定目前這個命令是否要執行(&& ||)。在結束 lftp 時, 如果還有程序執行中, lftp 會將自己切換到 no hup 模式並放到背景執行。因此不必擔心執行 lftp 當中無法登出。
) y( m. e8 I+ `4 q: w& M參數:: A6 u0 \% i, @( ]9 S) ?
lftp :~> help!<shell-command>alias [<name> [<value>]]anonbookmark [SUBCMD]cache [SUBCMD]cat [-b] <files>cd <rdir>chmod [OPTS] mode file...close [-a][re]cls [opts] [path/][pattern]debug [<level>|off] [-o <file>]du [options] <dirs>exit [<code>|bg]get [OPTS] <rfile> [-o <lfile>]glob [OPTS] <cmd> <args>help [<cmd>]history -w file|-r file|-c|-l [cnt]jobs [-v]kill all|<job_no>lcd <ldir>lftp [OPTS] <site>ls [<args>]mget [OPTS] <files>mirror [OPTS] [remote [local]]mkdir [-p] <dirs>module name [args]more <files>mput [OPTS] <files>mrm <files>mv <file1> <file2> [re]nlist [<args>]open [OPTS] <site>pget [OPTS] <rfile> [-o <lfile>]put [OPTS] <lfile> [-o <rfile>]pwd [-p]queue [OPTS] [<cmd>]quote <cmd>repeat [delay] [command]rm [-r] [-f] <files>rmdir [-f] <dirs>scache [<session_no>]set [OPT] [<var> [<val>]]site <site_cmd>source <file>user <user|URL> [<pass>]versionwait [<jobno>]zcat <files>zmore <files>可用 help command 來看更詳細的說明。如 help alias( r! M7 b, s; y/ e' i
範例:; H, y, o9 h0 }& [5 w: Z
!<shell-command>可執行本地端 shell 中的命令, 如 !ls /usr/local/bin/由於 lftp 並沒有 lls(顯示本地端檔案列表的指令), 故可用 !ls 來替代。alias [<name> [<value>]]定義別名alias less morealias reconnect "close; cd ."直接輸入 alias 即可看到目前定義了那些別名。如果只輸入 alias name 的話, 則是取消 name 這個別名。$ ~$ \5 s5 y7 l+ S; s, G
bookmark [SUBCMD]bookmark add name 用來新增名稱為 name 的書籤bookmark del name 刪除名稱為 name 的書籤bookmark list 顯示目前有設定那些書籤(另外直接打 bookmark 和 bookmark list 的結果一樣)bookmark edit 呼叫編輯器修改書籤 (~/.lftp/bookmarks)設定書籤, 可將目前站台及所在目錄設成書籤, 下次可直接進來, 不用再 cd 來 cd 去的( Y% J3 {1 S- P$ ?/ ^
cat [OPTS] files...就是 cat
* G) ~+ y! w! ]1 x  t: Pmore <files>功用和 cat <files> | more 一樣5 m8 {* i0 J" N: }9 o
zcat <files>可直接看 .gz 的文件
$ w7 }- `$ p" K7 Q9 l3 P; i. S2 Izmore <files>和 more 一樣, 但是可看 .gz 的文件
- F. ?. {4 A* x4 T6 Kchmod [OPTS] mode file...更改檔案權限chmod --recursive遞迴的更改權限cd <rdir> 切換遠端目錄cache [SUBCMD]管理 lftp 的 cache[re]ls [<args>]從 cache 中顯示遠端檔案列表rels 則不會從 cache 中讀取[re]cls [opts] [path/][pattern]從 cache 中顯示遠端的檔案列表, 應該算是 ls 的加強版, 有很多參數可用,應該是可用來產生各種不同>的檔案列表以供其他程式使用。recls 則不會從 cache 中讀取du [options] <dirs>計算遠端整個目錄佔用容量; D6 Y9 c( {  y* \: p1 \# c4 L( H
get [OPTS] <rfile> [-o <lfile>]抓取遠端檔案$ D) M* ~+ F) w' i" X
get rfile -o lfile抓 rfile 到本地改名為 lfile-c 為續傳-E 抓檔完成後, 將遠端的檔案砍了-a 為 ascii mode, 預設為 binary mode-O 設定 base directory 為本地端放檔案的目錄mget [OPTS] <files>下載遠端檔案(可用 wildcard expansion 也就是 *)pget [OPTS] <rfile> [-o <lfile>]使用多個連結來下載檔案, 預設為五個。-n 3 為三個連結jobs [-v]顯示目前有那些程序在背景執行-v 顯示詳細的資訊(-v 可多加幾個來顯示更詳細的資訊)lcd <ldir>切換本地端的目錄mirror [OPTS] [remote [local]]下載整個目錄(樓上的 get 只能用來抓檔案)-c 續傳-e 這個要小心一些, 比較遠端和本地端的檔案, 假如遠端沒有的, 就將本地端的檔案刪除, 也就是將本地端和遠端資料同步。-R 上傳整個目錄-n 只下載較新的檔案-r 不用遞迴到目錄中--parallel=n 同時下載 n 個檔案(預設一次只下載一個)module name [args]載入模組' q+ W- U& ?' D1 p( e" C
put [OPTS] <files> [-o <rfile>]上傳檔案
6 i, z6 B( P- W% emput [OPTS] <files>上傳檔案(可用 wildcard expansion 也就是 *)
$ |" M* w* ^% Pmv <file1> <file2>將遠端的 file1 改名為 file2, M& R) P( {2 ^) l" U( G
mrm <files>用 wildcard expansion 方式來刪除遠端檔案, I3 C5 b6 ^) Q$ C, U
open [OPTS] <site>開啟某個站台open -u <user>[,<pass>] -p <port> sitequeue [OPTS] [<cmd>]將 cmd 放到佇列中等待執行-d index 將編號為 index 的 job 刪除-m index new_index 將編號為 index 的 job 移至編號 new_index, 插隊專用。-n index 在編號 index 之前新增一個 job按 fg 開始下載wait [<jobno>]將背景執行中的程序移至前景(也可用 fg)kill all|<job_no>刪除全部的 jobs 或 job_no* x: S3 Z+ `( r/ l7 h1 _! f
repeat [delay] [command]每隔 delay 秒, 重覆執行 command, 預設是每隔一秒3 R& n0 t, ~# ]4 g3 S
rm [-r] [-f] <files>移除遠端檔案( x0 g( v' Q. X& B) [+ a- {
mkdir [-p] <dirs>建立遠端目錄/ [0 f0 \( `6 N! }6 o5 X
rmdir [-f] <dirs>移除遠端目錄1 W# v7 v3 Q8 @* p2 I: B
set [OPT] [<var> [<val>]]設定變數直接鍵入 set 可看目前定義了那些變數. _* ]/ G6 d. q/ C# {4 ^
source <file>讀取 file, 並執行 file 中的命令(應該是和 bash 中的 source 命令是一樣的吧)* o2 h, F9 g( Z! U9 W  e
debug [<level>|off] [-o <file>]設定 debug level 為 level-o 將輸出導向至 fileexit [<code>|bg]結束 lftp此時若還有 jobs, 則會將 lftp 放至背景執行, 繼續未完成的工作history -w file|-r file|-c|-l [cnt]和 bash 中的 history 功能一樣[re]nlist [<args>]只顯示遠端的檔名pwd [-p]顯示目前遠端所在目錄-p 連登入密碼也顯示scache [<session_no>]只打 scache 顯示目前所有的 session, 加上 session_no 可切換至其他的 session,) h, [; m. e4 ?4 @4 z7 s" \
對於同時開啟多個站台或同個站台不同目錄間切換。
0 {5 ^. {' e6 R3 t" J小弟有遇過某些站台, 一個 ip 只允許登入一次的,如果想同時抓好幾個檔案在不同目錄下,就只能一次抓一個,等到抓完了才能再切換到別的目錄去抓第二個, 這時 lftp 的 queue 就派上用場了。一般下了 get, mget 的話, 檔案就直接開始下載了, 這時就無法再切換到其他目錄了, 因此, 先將 queue 給停止, 首先下個 queue, 按 enter, 再下個 jobs 即可看到目前 queue 是停止的。這時再將要抓的東東一個個加入 queue 中, 等到要抓的東東都進入 queue 後, 再下 queue start 一次全部傳送, 這樣子可省去隨時注意檔案是否抓完,迼成困擾。
% b# i- k- r) W0 q7 R  n1 v* q0 Rlftp localhost:/pub/Iso> queuelftp localhost:/pub/Iso> jobs[0] queue (ftp://localhost)Queue is stopped.lftp localhost:/pub/Iso> queue get rettcd.isolftp localhost:/pub/Iso> jobs[0] queue (ftp://localhost)Queue is stopped.Commands queued:1. get rettcd.isolftp localhost:/pub/Iso> queue mirror Linux/lftp localhost:/pub/Iso> jobs[0] queue (ftp://localhost)Queue is stopped.Commands queued:1. get rettcd.iso2. mirror Linux/lftp localhost:/pub/Iso> queue startlftp localhost:/pub/Iso> jobs[0] queue (ftp://localhost)Now executing: [1] get rettcd.isoCommands queued:1. mirror Linux/[1] get rettcd.iso`rettcd.iso′ at 4772864 (9%) 3.00M/s eta:14s [Receiving data]以上大致為 lftp 的用法, 至於有幾個沒介紹的, 就是搞不懂作什麼用的啦。不過, 真覺得 lftp 實在太強了。

TOP

發新話題