歡迎您光臨本站 註冊首頁

我的Linux學習之旅(FTP命令&信息代碼全解)

←手機掃碼閱讀     火星人 @ 2014-03-29 , reply:0

FTP命令是大家使用最頻繁的命令之一,不論是在DOS還是OS/400、UNIX操 作系統下使用FTP,都會遇到大量的FTP內部命令。 熟悉並靈活應用FTP的內部 命令,可以大大方便使用者,並收到事半功倍之效。


FTP的命令行格式為: ftp -v -d -i -n -g [主機名] ,其中 -v 顯示遠程伺服器的所有響應信息; -n 限制ftp的自動登錄,即不使用; .n etrc文件; -d 使用調試方式; -g 取消全局文件名。


ftp使用的內部命令如下(中括弧表示可選項):


1.![cmd[args]]:在本地機中執行交互shell,exit回到ftp環境,如: !ls*.zip.


2.$ macro-ame[args]:執行宏定義macro-name.



3.account[password]:提供登錄遠程系統成功后訪問系統資源所需的補 充口令。



4.append local-file[remote-file]:將本地文件追加到遠程系統主機, 若未指定遠程系統文件名,則使用本地文件名。



5.ascii:使用ascii類型傳輸方式。



6.bell:每個命令執行完畢後計算機響鈴一次。



7.bin:使用二進位文件傳輸方式。



8.bye:退出ftp會話過程。



9.case:在使用mget時,將遠程主機文件名中的大寫轉為小寫字母。



10.cd remote-dir:進入遠程主機目錄。



11.cdup:進入遠程主機目錄的父目錄。



12.chmod mode file-name:將遠程主機文件file-name的存取方式設置為 mode,如: chmod 777 a.out 。



13.close:中斷與遠程伺服器的ftp會話(與open對應)。



14.cr:使用asscii方式傳輸文件時,將回車換行轉換為回行。



15.delete remote-file:刪除遠程主機文件。



16.debug[debug-value]:設置調試方式, 顯示發送至遠程主機的每條命 令,如: deb up 3,若設為0,表示取消debug。



17.dir[remote-dir][local-file]:顯示遠程主機目錄,並將結果存入本 地文件local-file。



18.disconnection:同close。



19.form format:將文件傳輸方式設置為format,預設為file方式。



20.get remote-file[local-file]: 將遠程主機的文件remote-file傳至 本地硬碟的local-file。



21.glob:設置mdelete,mget,mput的文件名擴展,預設時不擴展文件名, 同命令行的-g參數。



22.hash:每傳輸1024位元組,顯示一個hash符號(#)。



23.help[cmd]:顯示ftp內部命令cmd的幫助信息,如:help get。



24.idle[seconds]:將遠程伺服器的休眠計時器設為[seconds]秒。



25.image:設置二進位傳輸方式(同binary)。



26.lcd[dir]:將本地工作目錄切換至dir。



27.ls[remote-dir][local-file]:顯示遠程目錄remote-dir, 並存入本 地文件local-file。



28.macdef macro-name:定義一個宏,遇到macdef下的空行時,宏定義結 束。



29.mdelete[remote-file]:刪除遠程主機文件。



30.mdir remote-files local-file:與dir類似,但可指定多個遠程文件, 如: mdir *.o.*.zipoutfile 。



31.mget remote-files:傳輸多個遠程文件。



32.mkdir dir-name:在遠程主機中建一目錄。



33.mls remote-file local-file:同nlist,但可指定多個文件名。



34.mode[modename]:將文件傳輸方式設置為modename, 預設為stream方 式。



35.modtime file-name:顯示遠程主機文件的最後修改時間。



36.mput local-file:將多個文件傳輸至遠程主機。



37.newer file-name: 如果遠程機中file-name的修改時間比本地硬碟同 名文件的時間更近,則重傳該文件。



38.nlist[remote-dir][local-file]:顯示遠程主機目錄的文件清單,並 存入本地硬碟的local-file。



39.nmap[inpattern outpattern]:設置文件名映射機制, 使得文件傳輸 時,文件中的某些字元相互轉換,如:nmap $1.$2.$3[$1,$2].[$2,$3],則 傳輸文件a1.a2.a3時,文件名變為a1,a2。該命令特別適用於遠程主機為非UNIX 機的情況。



40.ntrans[inchars[outchars]]:設置文件名字元的翻譯機制,如ntrans 1R,則文件名LLL將變為RRR。



41.open host[port]:建立指定ftp伺服器連接,可指定連接埠。



42.passive:進入被動傳輸方式。



43.prompt:設置多個文件傳輸時的交互提示。



44.proxy ftp-cmd:在次要控制連接中,執行一條ftp命令, 該命令允許 連接兩個ftp伺服器,以在兩個伺服器間傳輸文件。第一條ftp命令必須為open, 以首先建立兩個伺服器間的連接。



45.put local-file[remote-file]:將本地文件local-file傳送至遠程主 機。



46.pwd:顯示遠程主機的當前工作目錄。



47.quit:同bye,退出ftp會話。



48.quote arg1,arg2...:將參數逐字發至遠程ftp伺服器,如: quote syst.



49.recv remote-file[local-file]:同get。



50.reget remote-file[local-file]:類似於get,但若local-file存在, 則從上次傳輸中斷處續傳。



51.rhelp[cmd-name]:請求獲得遠程主機的幫助。



52.rstatus[file-name]:若未指定文件名,則顯示遠程主機的狀態,否 則顯示文件狀態。



53.rename[from][to]:更改遠程主機文件名。



54.reset:清除回答隊列。



55.restart marker:從指定的標誌marker處,重新開始get或put,如: restart 130。



56.rmdir dir-name:刪除遠程主機目錄。



57.runique:設置文件名唯一性存儲,若文件存在,則在原文件后加後綴 ..1,.2等。



58.send local-file[remote-file]:同put。



59.sendport:設置PORT命令的使用。



60.site arg1,arg2...:將參數作為SITE命令逐字發送至遠程ftp主機。



61.size file-name:顯示遠程主機文件大小,如:site idle 7200。



62.status:顯示當前ftp狀態。



63.struct[struct-name]:將文件傳輸結構設置為struct-name, 預設時 使用stream結構。



64.sunique:將遠程主機文件名存儲設置為唯一(與runique對應)。



65.system:顯示遠程主機的操作系統類型。



66.tenex:將文件傳輸類型設置為TENEX機的所需的類型。



67.tick:設置傳輸時的位元組計數器。



68.trace:設置包跟蹤。



69.type[type-name]:設置文件傳輸類型為type-name,預設為ascii,如: type binary,設置二進位傳輸方式。



70.umask[newmask]:將遠程伺服器的預設umask設置為newmask,如: umask 3。



71.user user-name[password][account]:向遠程主機表明自己的身份, 需要口令時,必須輸入口令,如:user anonymous my@email。



72.verbose:同命令行的-v參數,即設置詳盡報告方式,ftp伺服器的所有 響應都將顯示給用戶,預設為on.



73.?[cmd]:同help.







--------------------------------------------------------------------------------






FTP信息代碼全解
-----------------------------------
110 Restart marker reply. In this case, the text is exact and not left to the particular implementation; it must read: MARK yyyy = mmmm where yyyy is User-process data stream marker, and mmmm server''s equivalent marker (note the spaces between markers and "=").
重新啟動標誌回應。這種情況下,信息是精確的並且不用特別的處理;可以這樣看:標記 yyyy = mmm 中 yyyy是 用戶進程數據流標記,mmmm是伺服器端相應的標記(注意在標記和等號間的空格)
-----------------------------------
120 Service ready in nnn minutes.
服務在NNN時間內可用
-----------------------------------
125 Data connection already open; transfer starting.
數據連接已經打開,開始傳送數據.
-----------------------------------
150 File status okay; about to open data connection.
文件狀態正確,正在打開數據連接.
-----------------------------------
200 Command okay.
命令執行正常結束.
-----------------------------------
202 Command not implemented, superfluous at this site.
命令未被執行,此站點不支持此命令.
-----------------------------------
211 System status, or system help reply.
系統狀態或系統幫助信息回應.
-----------------------------------
212 Directory status.
目錄狀態信息.
-----------------------------------
213 File status.
文件狀態信息.
-----------------------------------
214 Help message.On how to use the server or the meaning of a particular non-standard command. This reply is useful only to the human user. 幫助信息。關於如何使用本伺服器或特殊的非標準命令。此回復只對人有用。
-----------------------------------
215 NAME system type. Where NAME is an official system name from the list in the Assigned Numbers document.
NAME系統類型。
-----------------------------------
220 Service ready for new user.
新連接的用戶的服務已就緒
-----------------------------------
221 Service closing control connection.
控制連接關閉
-----------------------------------
225 Data connection open; no transfer in progress.
數據連接已打開,沒有進行中的數據傳送
-----------------------------------
226 Closing data connection. Requested file action successful (for example, file transfer or file abort).
正在關閉數據連接。請求文件動作成功結束(例如,文件傳送或終止)
-----------------------------------
227 Entering Passive Mode (h1,h2,h3,h4,p1,p2).
進入被動模式
-----------------------------------
230 User logged in, proceed. Logged out if appropriate.
用戶已登入。 如果不需要可以登出。
-----------------------------------
250 Requested file action okay, completed.
被請求文件操作成功完成
-----------------------------------
257 "PATHNAME" created.
路徑已建立
-----------------------------------
331 User name okay, need password.
用戶名存在,需要輸入密碼
-----------------------------------
332 Need account for login.
需要登陸的賬戶
-----------------------------------
350 Requested file action pending further information
對被請求文件的操作需要進一步更多的信息
-----------------------------------
421 Service not available, closing control connection.This may be a reply to any command if the service knows it must shut down.
服務不可用,控制連接關閉。這可能是對任何命令的回應,如果服務認為它必須關閉
-----------------------------------
425 Can''t open data connection.
打開數據連接失敗
-----------------------------------
426 Connection closed; transfer aborted.
連接關閉,傳送中止。
-----------------------------------
450 Requested file action not taken.
對被請求文件的操作未被執行
-----------------------------------
451 Requested action aborted. Local error in processing.
請求的操作中止。處理中發生本地錯誤。
-----------------------------------
452 Requested action not taken. Insufficient storage space in system.File unavailable (e.g., file busy).
請求的操作沒有被執行。 系統存儲空間不足。 文件不可用
-----------------------------------
500 Syntax error, command unrecognized. This may include errors such as command line too long.
語法錯誤,不可識別的命令。 這可能是命令行過長。
-----------------------------------
501 Syntax error in parameters or arguments.
參數錯誤導致的語法錯誤
-----------------------------------
502 Command not implemented.
命令未被執行
-----------------------------------
503 Bad sequence of commands.
命令的次序錯誤。
-----------------------------------
504 Command not implemented for that parameter.
由於參數錯誤,命令未被執行
-----------------------------------
530 Not logged in.
沒有登錄
-----------------------------------
532 Need account for storing files.
存儲文件需要賬戶信息
-----------------------------------
550 Requested action not taken. File unavailable (e.g., file not found, no access).
請求操作未被執行,文件不可用。
-----------------------------------
551 Requested action aborted. Page type unknown.
請求操作中止,頁面類型未知
-----------------------------------
552 Requested file action aborted. Exceeded storage allocation (for current directory or dataset).
對請求文件的操作中止。 超出存儲分配
-----------------------------------
553 Requested action not taken. File name not allowed
請求操作未被執行。 文件名不允許
-----------------------------------
-----------------------------------
這種錯誤跟http協議類似,大致是:
2開頭--成功
3開頭--許可權問題
4開頭--文件問題
5開頭--伺服器問題

[火星人 ] 我的Linux學習之旅(FTP命令&信息代碼全解)已經有585次圍觀

http://coctec.com/docs/linux/show-post-203993.html