<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d6154817622702903944\x26blogName\x3d%E2%97%8B%E3%80%82o%E5%82%BB%E3%80%83%E4%BB%94%E3%80%83%E4%BB%94o%E3%80%82\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dSILVER\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttps://vincent1303.blogspot.com/search\x26blogLocale\x3dzh_TW\x26v\x3d2\x26homepageUrl\x3dhttp://vincent1303.blogspot.com/\x26vt\x3d682101390609131817', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Lftp的指令介紹


摘自摩托學園討論區:http://moto.debian.org.tw/viewtopic.php?t=2182 

指令名稱:lftp

簡要功能說明:多才多藝的檔案傳輸工具



詳細說明: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 當中無法登出。

參數:
lftp :~> help
!<shell-command>
alias [<name> [<value>]]
anon
bookmark [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>]
version
wait [<jobno>]
zcat <files>
zmore <files>

可用 help command 來看更詳細的說明
如 help alias

範例:

!<shell-command>
可執行本地端 shell 中的命令, 如 !ls /usr/local/bin/
由於 lftp 並沒有 lls(顯示本地端檔案列表的指令), 故可用 !ls 來替代。

alias [<name> [<value>]]
定義別名
alias less more
alias reconnect "close; cd ."
直接輸入 alias 即可看到目前定義了那些別名。如果只輸入 alias name 的話, 則是取消 name 這個別名。


bookmark [SUBCMD]
設定書籤, 可將目前站台及所在目錄設成書籤, 下次可直接進來, 不用再 cd 來 cd 去的

bookmark add name 用來新增名稱為 name 的書籤
bookmark del name 刪除名稱為 name 的書籤
bookmark list 顯示目前有設定那些書籤(另外直接打 bookmark 和 bookmark list 的結果一樣)
bookmark edit 呼叫編輯器修改書籤 (~/.lftp/bookmarks)


cat [OPTS] files...
就是 cat 啦


more <files>
功用和 cat <files> | more 一樣


zcat <files>
可直接看 .gz 的文件


zmore <files>
和 more 一樣, 但是可看 .gz 的文件


chmod [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>
計算遠端整個目錄佔用容量


get [OPTS] <rfile> [-o <lfile>]
抓取遠端檔案

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]
載入模組


put [OPTS] <files> [-o <rfile>]
上傳檔案


mput [OPTS] <files>
上傳檔案(可用 wildcard expansion 也就是 *)


mv <file1> <file2>
將遠端的 file1 改名為 file2


mrm <files>
用 wildcard expansion 方式來刪除遠端檔案


open [OPTS] <site>
開啟某個站台
open -u <user>[,<pass>] -p <port> site


queue [OPTS] [<cmd>]
將 cmd 放到佇列中等待執行
-d index 將編號為 index 的 job 刪除
-m index new_index 將編號為 index 的 job 移至編號 new_index, 插隊專用。
-n index 在編號 index 之前新增一個 job


wait [<jobno>]
將背景執行中的程序移至前景(也可用 fg)


kill all|<job_no>
刪除全部的 jobs 或 job_no


repeat [delay] [command]
每隔 delay 秒, 重覆執行 command, 預設是每隔一秒


rm [-r] [-f] <files>
移除遠端檔案


mkdir [-p] <dirs>
建立遠端目錄


rmdir [-f] <dirs>
移除遠端目錄


set [OPT] [<var> [<val>]]
設定變數
直接鍵入 set 可看目前定義了那些變數


source <file>
讀取 file, 並執行 file 中的命令(應該是和 bash 中的 source 命令是一樣的吧)


debug [<level>|off] [-o <file>]
設定 debug level 為 level
-o 將輸出導向至 file


exit [<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,
對於同時開啟多個站台或同個站台不同目錄間切換。




小弟有遇過某些站台, 一個 ip 只允許登入一次的,如果想同時抓好幾個檔案在不同目錄下,就
只能一次抓一個,等到抓完了才能再切換到別的目錄去抓第二個, 這時 lftp 的 queue 就派上
用場了。一般下了 get, mget 的話, 檔案就直接開始下載了, 這時就無法再切換到其他目錄了, 因此, 先將 queue 給停止, 首先下個 queue, 按 enter, 再下個 jobs 即可看到目前 qu
eue 是停止的。這時再將要抓的東東一個個加入 queue 中, 等到要抓的東東都進入 queue 後
, 再下 queue start 一次全部傳送, 這樣子可省去隨時注意檔案是否抓完,迼成困擾。

lftp localhost:/pub/Iso> queue

lftp localhost:/pub/Iso> jobs
[0] queue (ftp://localhost)
Queue is stopped.

lftp localhost:/pub/Iso> queue get rettcd.iso

lftp localhost:/pub/Iso> jobs
[0] queue (ftp://localhost)
Queue is stopped.
Commands queued:
1. get rettcd.iso

lftp localhost:/pub/Iso> queue mirror Linux/

lftp localhost:/pub/Iso> jobs
[0] queue (ftp://localhost)
Queue is stopped.
Commands queued:
1. get rettcd.iso
2. mirror Linux/

lftp localhost:/pub/Iso> queue start

lftp localhost:/pub/Iso> jobs
[0] queue (ftp://localhost)
Now executing: [1] get rettcd.iso
Commands queued:
1. mirror Linux/
[1] get rettcd.iso
`rettcd.iso' at 4772864 (9%) 3.00M/s eta:14s [Receiving data]




以上大致為 lftp 的用法, 至於有幾個沒介紹的, 就是搞不懂作什麼用的啦。不過, 真覺得 lftp 實在太強了。

Link from

“ Lftp的指令介紹 ”