打印

lftp

lftp

' H, u* j( ?8 F8 w
lftp DebianWiki | RecentChanges | Preferences 0 u5 b/ b: u, z9 h0 R/ ?6 R& q
5 G) ]. a9 A' h5 N
lftp支援SSL傳輸的FTP Clients, b  R, s! Q9 m
指令名稱:lftp' g' S: x$ r, o  i6 f; [7 ~+ r( ^$ D
簡要功能說明:多才多藝的檔案傳輸工具。
8 ?, ^3 b' B& ~詳細說明: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 當中無法登出。5 w6 `) I# y$ l/ l( @
參數:
/ Q- I: Y  f! Slftp :~> 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
) s& w7 E7 a- ?( P! a. |0 I範例:! ^3 S, L8 `& n; c6 \
!<shell-command>可執行本地端 shell 中的命令, 如 !ls /usr/local/bin/由於 lftp 並沒有 lls(顯示本地端檔案列表的指令), 故可用 !ls 來替代。alias [<name> [<value>]]定義別名alias less morealias reconnect "close; cd ."直接輸入 alias 即可看到目前定義了那些別名。如果只輸入 alias name 的話, 則是取消 name 這個別名。5 x1 z. [* p4 `, b
bookmark [SUBCMD]bookmark add name 用來新增名稱為 name 的書籤bookmark del name 刪除名稱為 name 的書籤bookmark list 顯示目前有設定那些書籤(另外直接打 bookmark 和 bookmark list 的結果一樣)bookmark edit 呼叫編輯器修改書籤 (~/.lftp/bookmarks)設定書籤, 可將目前站台及所在目錄設成書籤, 下次可直接進來, 不用再 cd 來 cd 去的
) a* p5 {, r% V% Lcat [OPTS] files...就是 cat3 b# c  _4 J3 H! ?9 `) I+ E
more <files>功用和 cat <files> | more 一樣
4 o& k* \  m1 B7 j  pzcat <files>可直接看 .gz 的文件
( z. l& C& t8 B8 Vzmore <files>和 more 一樣, 但是可看 .gz 的文件
" r/ Y+ H' s" O# x# |3 u* vchmod [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 W% X1 G/ {# c* s0 z# t; y; `' B- vget [OPTS] <rfile> [-o <lfile>]抓取遠端檔案
- o# {. c. _8 H% Eget 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]載入模組, d, `% s/ t- w6 @: [; b. R
put [OPTS] <files> [-o <rfile>]上傳檔案
! s5 K* U7 B  c3 L% amput [OPTS] <files>上傳檔案(可用 wildcard expansion 也就是 *)
% N0 ?* H: q) m2 _mv <file1> <file2>將遠端的 file1 改名為 file2
# j+ A5 p  ^  A# v$ fmrm <files>用 wildcard expansion 方式來刪除遠端檔案6 u' b. y7 L: b( e
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
# J6 O, W) W1 I# U3 H, S. v3 N* Prepeat [delay] [command]每隔 delay 秒, 重覆執行 command, 預設是每隔一秒9 X! W4 l% I( A2 [% D/ Y7 X
rm [-r] [-f] <files>移除遠端檔案
! g' Q* _* |- f* A7 vmkdir [-p] <dirs>建立遠端目錄$ G# _1 e- q- k9 q
rmdir [-f] <dirs>移除遠端目錄+ _4 O6 B, c  x# f8 s% \* ~7 g8 Z
set [OPT] [<var> [<val>]]設定變數直接鍵入 set 可看目前定義了那些變數
. o* T+ u8 Q; `5 nsource <file>讀取 file, 並執行 file 中的命令(應該是和 bash 中的 source 命令是一樣的吧)$ S& W, ?7 S! C5 B9 m+ V
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,
  C7 ?7 F$ N# S' W& u- M& a對於同時開啟多個站台或同個站台不同目錄間切換。
( k3 D  I2 h7 n: W  @+ m小弟有遇過某些站台, 一個 ip 只允許登入一次的,如果想同時抓好幾個檔案在不同目錄下,就只能一次抓一個,等到抓完了才能再切換到別的目錄去抓第二個, 這時 lftp 的 queue 就派上用場了。一般下了 get, mget 的話, 檔案就直接開始下載了, 這時就無法再切換到其他目錄了, 因此, 先將 queue 給停止, 首先下個 queue, 按 enter, 再下個 jobs 即可看到目前 queue 是停止的。這時再將要抓的東東一個個加入 queue 中, 等到要抓的東東都進入 queue 後, 再下 queue start 一次全部傳送, 這樣子可省去隨時注意檔案是否抓完,迼成困擾。
( x9 |' d' h1 Y9 olftp 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

發新話題