天天看點

使用FTP自動進行檔案傳輸

使用FTP自動進行檔案傳輸

四篇相關文檔

  巧用FTP進行檔案傳輸

陳興達

 ---- Internet作為現代資訊高速公路已深入我們的生活,其中它所提供的電子郵件Web網站資訊服務已被越來越多的人所熟知和使用。FTP作為Internet的功能之一,雖然沒有像E-mail和Web網站資訊服務那樣得到廣泛使用,但是它在Internet上的檔案傳輸功能,受到了一些專業人士的青睐。

---- 下面向您介紹兩則利用FTP進行檔案傳輸的方法。

一、批量檔案傳輸法

---- 适用範圍: 單純檔案傳輸,同時檔案名又有一定的規律性,如有相同的檔案擴充名等。

---- 使用環境: 含有DOS的作業系統。

---- 實作原理: 利用FTP的“-i -s”選項。

---- 具體方法:

---- 在C槽建立子目錄“ftp”,以下所有操作在此目錄裡完成。

建立一個包含FTP基本指令的純文字檔案ftpbta,内容如下:

yourname

; 用于登入ftp檔案伺服器的賬号

password

; 登入用密碼

bell

; 當完成指令時,發出Beep 聲

cd directory

; 進入檔案指定存儲的目錄

binary

; 設定binary 傳輸方法

mput *.jpg

; 上傳此目錄下的所有.jpg檔案

mput *.html

; 在上傳此目錄下的所有.html檔案

bye

; 終止并退出ftp

建立一個批處理檔案ftpbta.bat,調用ftp指令,檔案内容如下:

ftp -i -s:ftpbta ftpserver

; ftpserver為ftp檔案伺服器名或IP位址

拷貝所要傳輸的檔案到C:ftp目錄,然後運作ftpbta.bat批處理檔案,系統将自動執行檔案ftpbta裡設定的FTP指令,無需使用者幹預即可完成檔案傳輸。

二、IE浏覽器檔案傳輸法

---- 适用範圍: 所要傳輸的内容比較複雜,包含有檔案和目錄。

---- 使用環境: 含有Internet Explorer 5.0以上版本浏覽器的作業系統。

---- 實作原理: 利用Internet Explorer自身所帶的FTP功能。

---- 具體方法:

---- 1.登入FTP檔案伺服器

---- 啟動IE浏覽器,在位址欄中輸入“ftp://[email protected]”,回車确認後,出現登入視窗

---- 當輸入正确的使用者名和密碼後,顯示此使用者在FTP檔案伺服器上的目錄---- 2.上傳檔案

---- 将所要上傳的檔案直接拖入FTP檔案伺服器視窗。

---- 3.下載下傳檔案或目錄

---- 選擇所要下載下傳的檔案,點選菜單欄中的“檔案”*“複制到檔案夾”後,打開“浏覽檔案夾”視窗(如圖3所示),選擇檔案夾後,單擊“确定”完成檔案下載下傳。

---- 對FTP檔案伺服器上的檔案,隻有您擁有正确的使用者名和密碼,才可進行删除、重命名操作,但檔案不能在FTP站點内部和站點之間移動。在最新的Internet Explorer 5.5 中,此問題仍然存在。

---- 以上是兩則FTP的簡單應用,适合于Internet上的一般檔案傳輸。如是管理網站等用到的複雜檔案傳輸,推薦您使用專用的FTP軟體,如Dreamwaver和CuteFtp,其中Dreamwaver是一個很好的頁面制作、網站管理和檔案傳輸軟體,值得朋友們一用。我們也将在今後的文章中向大家介紹一些Dreamwaver的使用技巧。

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

給一個在windows下的參考:

1)建立一個批檔案如:ftp.bat,内容如下:

ftp -i -s:C:ftpftpprofile.ini

2)在c:ftp建立一個ftpprocfile.ini檔案,其内容如下(#後為注釋):

open 192.168.1.200        #連接配接

new                  #ftp使用者名

321                   #ftp使用者密碼

cd /var/ftp/new

lcd C:/ftp/ftpfile

mget *.exe

mget *.EXE

mget *.pbd

mget *.PBD

mget *.bmp

mget *.BMP

mget *.PIF

ascii

mget *.ini

mget *.INI

mget *.txt

mget *.TXT

mget *.bat

mget *.BAT

bye

3)若想定時執行,将ftp.bat加入到"計劃任務"中

原文1位址: http://www.moon-soft.com/book/qyftpjxwjcs.htm

=======================

給一個在windows下的參考:

1)建立一個批檔案如:ftp.bat,内容如下:

ftp -i -s:C:ftpftpprofile.ini

2)在c:ftp建立一個ftpprocfile.ini檔案,其内容如下(#後為注釋):

open 192.168.1.200        #連接配接

new                  #ftp使用者名

321                   #ftp使用者密碼

cd /var/ftp/new

lcd C:/ftp/ftpfile

mget *.exe

mget *.EXE

mget *.pbd

mget *.PBD

mget *.bmp

mget *.BMP

mget *.PIF

ascii

mget *.ini

mget *.INI

mget *.txt

mget *.TXT

mget *.bat

mget *.BAT

bye

3)若想定時執行,将ftp.bat加入到"計劃任務"中

……

原文2位址: http://bbs.chinaunix.net/viewthread.php?tid=732202

=======================

How do I automatically FTP using NT?

A Web Exclusive from FAQ for Windows

John Savill

Network

InstantDoc #14457

FAQ for Windows InstantDoc #14457

A. I use a basic script to update my main site and the mirrors using two batch files. The first consists of a few lines:

d:

cd savilltechhomepage

ftp -i -s:d:savmanagementgoftp.bat

The -i suppresses the prompt when performing a multiple put, and the -s defines an input file for the FTP like:

open ftp.savilltech.com - the name of the FTP server

johnny - username

secret - password

cd /www - remotely move to a base directory

lcd download - locally change directory

cd download - remotely move to a sub directory of the current directory

binary - set mode to binary

put faqcomp.zip - send a file

cd .. - move down a directory remotely

lcd .. - move down a directory locally

cd ntfaq

lcd ntfaq

mput *.html - send multiple files (this is why we needed -i)

close - close the connection

原文位址: http://www.windowsitpro.com/Article/ArticleID/14457/14457.html

========================

FTP指令是Internet使用者使用最頻繁的指令之一,不論是在DOS還是UNIX作業系統下使用FTP,都會遇到大量的FTP内部指令。熟悉并靈活應用FTP的内部指令,可以大大友善使用者,并收到事半功倍之效。下面以Win9x的DOS視窗中的FTP指令為例,介紹一下其用法。 (本站注:若想在純DOS下使用FTP指令,則需先加載網絡裝置如網卡或數據機的Packet驅動程式,再使用本站“網絡工具”中的Wattcp FTP程式,其用法與下面介紹的類似,詳情請見本站的“DOS使用”欄目)

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。

原文位址:http://www.dvbbs.net/tech/network/2006042554661.asp

繼續閱讀