, f7 b+ n8 y8 @( ?. O1 i# i
lftp DebianWiki |
RecentChanges |
Preferences % [! o/ \3 X* G, }
, m- D! ?* x. W# P; b
lftp支援SSL傳輸的FTP Clients
8 Q5 y5 F2 w9 g, Z7 O6 s
指令名稱:lftp
) V3 ]' f9 I0 L0 @2 G簡要功能說明:多才多藝的檔案傳輸工具。
1 c4 L% \' ] \; @6 B* F
詳細說明: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 當中無法登出。
/ ^2 \; r" O: b
參數:
0 U) D7 X' }, Nlftp :~> 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
; X. o* P4 K4 S Z2 r4 h範例:
~- U6 E( b# q2 M1 F/ ^
!<shell-command>可執行本地端 shell 中的命令, 如 !ls /usr/local/bin/由於 lftp 並沒有 lls(顯示本地端檔案列表的指令), 故可用 !ls 來替代。alias [<name> [<value>]]定義別名alias less morealias reconnect "close; cd ."直接輸入 alias 即可看到目前定義了那些別名。如果只輸入 alias name 的話, 則是取消 name 這個別名。
! K' u% n4 ]3 l Z
bookmark [SUBCMD]bookmark add name 用來新增名稱為 name 的書籤bookmark del name 刪除名稱為 name 的書籤bookmark list 顯示目前有設定那些書籤(另外直接打 bookmark 和 bookmark list 的結果一樣)bookmark edit 呼叫編輯器修改書籤 (~/.lftp/bookmarks)設定書籤, 可將目前站台及所在目錄設成書籤, 下次可直接進來, 不用再 cd 來 cd 去的
( t/ E2 u3 o! [7 r
cat [OPTS] files...就是
cat 啦
5 d/ F/ x. _5 G
more <files>功用和 cat <files> | more 一樣
) E* M" w6 z: G
zcat <files>可直接看 .gz 的文件
8 ~. b* n9 t* U9 v9 W
zmore <files>和 more 一樣, 但是可看 .gz 的文件
4 a0 |- z' J3 {7 k3 _# G7 }& Uchmod [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>計算遠端整個目錄佔用容量
2 k2 H3 D( [/ D7 n- oget [OPTS] <rfile> [-o <lfile>]抓取遠端檔案
* P' D3 r7 w H) Gget 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]載入模組
7 b/ s7 w! [9 F6 ?% }2 I
put [OPTS] <files> [-o <rfile>]上傳檔案
8 [/ z2 C; z) a; Imput [OPTS] <files>上傳檔案(可用 wildcard expansion 也就是 *)
1 p& [2 `3 p* ^" H
mv <file1> <file2>將遠端的 file1 改名為 file2
9 \7 L- Y3 t, Z7 `; w8 u& x0 Zmrm <files>用 wildcard expansion 方式來刪除遠端檔案
# ]9 S, Z- h& _7 J
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
3 U( w/ W2 h, P& ^8 N$ X4 W! ^
repeat [delay] [command]每隔 delay 秒, 重覆執行 command, 預設是每隔一秒
. E' y* C; q+ w
rm [-r] [-f] <files>移除遠端檔案
4 B! }7 G7 ?+ D+ `6 Y& C! r1 E
mkdir [-p] <dirs>建立遠端目錄
/ H& S0 K" o7 I4 f+ j: }1 c. _) frmdir [-f] <dirs>移除遠端目錄
4 `! W3 u& p3 J u- t$ B
set [OPT] [<var> [<val>]]設定變數直接鍵入 set 可看目前定義了那些變數
+ K2 b8 m; M2 H8 Q, y) hsource <file>讀取 file, 並執行 file 中的命令(應該是和 bash 中的 source 命令是一樣的吧)
: J8 b. m* D3 ^" |& ]5 y/ E' q
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,
) N4 T' w/ X7 d6 P對於同時開啟多個站台或同個站台不同目錄間切換。
7 B+ D) E8 M3 u6 z" [$ |
小弟有遇過某些站台, 一個 ip 只允許登入一次的,如果想同時抓好幾個檔案在不同目錄下,就只能一次抓一個,等到抓完了才能再切換到別的目錄去抓第二個, 這時 lftp 的 queue 就派上用場了。一般下了 get, mget 的話, 檔案就直接開始下載了, 這時就無法再切換到其他目錄了, 因此, 先將 queue 給停止, 首先下個 queue, 按 enter, 再下個 jobs 即可看到目前 queue 是停止的。這時再將要抓的東東一個個加入 queue 中, 等到要抓的東東都進入 queue 後, 再下 queue start 一次全部傳送, 這樣子可省去隨時注意檔案是否抓完,迼成困擾。
5 Z0 U$ d( A" H6 R% [: \; O$ @5 R, w
lftp 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 實在太強了。