實現FTP自動傳輸檔案

2021-04-17 22:20:34 字數 1724 閱讀 2789

實現ftp自動傳輸檔案

一、linux環境使用.netrc

在linux下可以使用.netrc檔案來達到自動傳輸的目的。

1. 在當前使用者目錄下建立.netrc檔案,內容如下:

$ cat ~/.netrc

machine 192.168.1.117 login oracle9i password oracle9i

macdef init

binput oracle.tar

quit

說明:「machine 192.168.1.117」也可以是"default";

macdef是定義巨集,名字為init表示登陸後自動執行,巨集以空行結束;

.netrc的許可權必須是600。

2. 操作示例

$ ftp 192.168.1.117

connected to 192.168.1.117.

220 (vsftpd 2.0.1)

530 please login with user and pass.

530 please login with user and pass.

kerberos_v4 rejected as an authentication type

331 please specify the password.

230 login successful.

bin200 switching to binary mode.

put snapassure.5.0.4.3.tar

local: snapassure.5.0.4.3.tar remote: snapassure.5.0.4.3.tar

227 entering passive mode (192,168,1,117,78,144)

150 ok to send data.

226 file receive ok.

1699840 bytes sent in 0.18 seconds (9.5e+03 kbytes/s)

quit

221 goodbye.

二、 windows環境

windows下ftp提供了乙個-s引數,結合-n就可以實現自動傳輸了。

1. 在當前目錄下建立test.ftp,內容如下:

d:/>type test.ftp

open 192.168.1.154

user oracle9i

oracle9i

put test.txt

quit

d:/>

2. 操作示例

d:/>ftp -n -s:test.ftp

ftp> open 192.168.1.154

connected to 192.168.1.154.

220 (vsftpd 1.2.0)

ftp> user oracle9i

331 please specify the password.

230 login successful.

ftp> put test.txt

200 port command successful. consider using pasv.

150 ok to send data.

226 file receive ok.

ftp: 傳送 63 位元組,用時 0.00seconds 63000.00kbytes/sec.

ftp> quit

221 goodbye.

linux指令碼 ftp自動傳輸檔案

open 192.168.1.171user guest 123456 cd home data lcd home databackup serverip,username,passwd,remote routine,local routine,這些最好以傳參變數形式編寫。eg open 1 用的時...

FTP檔案傳輸

ftp專案作業 要求 1.使用者加密認證 2.允許同時多使用者登入 3.每個使用者有自己的家目錄,且只能訪問自己的家目錄 4.對使用者進行磁碟配額,每個使用者的可用空間不同 5.允許使用者在ftp server上隨意切換目錄 6.允許使用者檢視當前目錄下的檔案 8.檔案傳輸過程中顯示進度條 9.支援...

Python實現FTP檔案傳輸的例項

ftp一般流程 ftp對應pasv和port兩種訪問方式,分別為被動和主動,是針對ftp伺服器端進行區分的,正常傳輸過程中21號埠用於指令傳輸,資料傳輸埠使用其他埠。pasv 由客戶端發起資料傳輸請求,伺服器端返回並攜帶資料埠,並且伺服器端開始監聽此埠等待資料,為被動模式 port 客戶端監聽埠並向...