打印

lftp

lftp

1 O% W: A- a( B! y! G  r, b3 h9 s* R
lftp DebianWiki | RecentChanges | Preferences 9 k% w" p1 w5 B3 g1 u5 k9 j" _& d5 p- Z

1 q% i1 B$ K4 _% k3 Y2 xlftp支援SSL傳輸的FTP Clients
  A) {5 [, N( f0 Z, Q8 g& A指令名稱:lftp
, d4 o$ A4 H6 `( y6 c簡要功能說明:多才多藝的檔案傳輸工具。
$ K0 F% {; w1 R$ p詳細說明: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 當中無法登出。
0 Z0 ?% K4 w3 X# |0 w參數:& ?* ~' D, x9 u# j! \
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
4 G8 L, k8 ~4 j; N' h7 A7 t" w3 }  c範例:0 ~8 W- O# w0 ~5 [" V* N
!<shell-command>可執行本地端 shell 中的命令, 如 !ls /usr/local/bin/由於 lftp 並沒有 lls(顯示本地端檔案列表的指令), 故可用 !ls 來替代。alias [<name> [<value>]]定義別名alias less morealias reconnect "close; cd ."直接輸入 alias 即可看到目前定義了那些別名。如果只輸入 alias name 的話, 則是取消 name 這個別名。
3 i% t" Z9 s& v9 R" M1 }bookmark [SUBCMD]bookmark add name 用來新增名稱為 name 的書籤bookmark del name 刪除名稱為 name 的書籤bookmark list 顯示目前有設定那些書籤(另外直接打 bookmark 和 bookmark list 的結果一樣)bookmark edit 呼叫編輯器修改書籤 (~/.lftp/bookmarks)設定書籤, 可將目前站台及所在目錄設成書籤, 下次可直接進來, 不用再 cd 來 cd 去的
7 D( N" E& _+ D- ~# x. wcat [OPTS] files...就是 cat0 M- o1 E! Z" W0 E# v* d2 Q
more <files>功用和 cat <files> | more 一樣
/ o$ K8 r4 p$ s( _8 xzcat <files>可直接看 .gz 的文件5 X( L& j1 \7 Y& `8 Z
zmore <files>和 more 一樣, 但是可看 .gz 的文件
2 K. ^, p' J8 B+ Ochmod [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>計算遠端整個目錄佔用容量
* f) r. r$ |" i$ e- dget [OPTS] <rfile> [-o <lfile>]抓取遠端檔案7 Z" v0 c6 t  q( S
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]載入模組* s7 s5 ]1 k) M/ m2 D& A8 }0 F
put [OPTS] <files> [-o <rfile>]上傳檔案
6 i/ y( a" U. o9 }mput [OPTS] <files>上傳檔案(可用 wildcard expansion 也就是 *)
+ U& h8 F$ D7 h8 h- Lmv <file1> <file2>將遠端的 file1 改名為 file20 N+ M7 g2 R7 z" Q+ i
mrm <files>用 wildcard expansion 方式來刪除遠端檔案# D! `9 ]) C7 G3 Y( s7 a
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
& o( f+ H& {0 C& H! S& O( p$ vrepeat [delay] [command]每隔 delay 秒, 重覆執行 command, 預設是每隔一秒7 k# l0 W% p; V3 K' W5 k& C- p
rm [-r] [-f] <files>移除遠端檔案. A' r, s/ R' g9 A7 C( c
mkdir [-p] <dirs>建立遠端目錄
% l& x+ L1 p! `: L% U1 Urmdir [-f] <dirs>移除遠端目錄8 O" ]+ F. M$ Z. C3 W+ E: Z
set [OPT] [<var> [<val>]]設定變數直接鍵入 set 可看目前定義了那些變數
1 j: C% ]  s  y: y7 g+ ^" ]+ F2 msource <file>讀取 file, 並執行 file 中的命令(應該是和 bash 中的 source 命令是一樣的吧)
% \1 L5 F; ^7 {0 J+ n  `7 I, Fdebug [<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,
+ P" q8 w$ M  n& u對於同時開啟多個站台或同個站台不同目錄間切換。7 p0 U" ^! d8 `* F
小弟有遇過某些站台, 一個 ip 只允許登入一次的,如果想同時抓好幾個檔案在不同目錄下,就只能一次抓一個,等到抓完了才能再切換到別的目錄去抓第二個, 這時 lftp 的 queue 就派上用場了。一般下了 get, mget 的話, 檔案就直接開始下載了, 這時就無法再切換到其他目錄了, 因此, 先將 queue 給停止, 首先下個 queue, 按 enter, 再下個 jobs 即可看到目前 queue 是停止的。這時再將要抓的東東一個個加入 queue 中, 等到要抓的東東都進入 queue 後, 再下 queue start 一次全部傳送, 這樣子可省去隨時注意檔案是否抓完,迼成困擾。
, I9 Z- }5 N) `* Q6 d4 _' i; slftp 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

發新話題