引用 | 編輯
SENFO
2005-03-22 10:05 |
樓主
▼ |
||
x0
利用 .netrc 的方式,不過不知道版本改到現在這東西還能不能用 試述如下,有錯的話請大家指教... 首先就是在自己的家目錄裡建立一個叫 .netrc 的檔,屬性為 600 也就是像這樣的: -rw------- 1 shaking shaking 567 Nov 30 12:00 .netrc 這個檔的內容如下: 複製程式 machine [對方主機的 domain] login [ID] password "[密碼]" macdef init bin lcd /to/the/dir/you/want/in-your-machine cd /to/the/dir/of-remote prompt mget *.ext bye macdef init 表示開始輸入指令 bin 表示以二元方式傳檔 lcd /to/the/dir/you/want/in-your-machine 轉到本地機器中你要儲存檔案的目錄 cd /to/the/dir/of-remote 轉到遠端你要下載的目標檔案所在目錄 prompt off 這個指令在一次抓很多個檔的時候就不會一個一個問 y or n 了 mget *.ext 抓檔 (ps 在這個部份,你也可以用 get filename.ext 抓多個檔,多打幾行就是了,如果需要的話) bye 離開(離線) 這裡有個地方要注意的,就是在 bye 後面一定要空一行。 這個 script 可以類似這樣的方式 在一個檔裡面指定向好幾台機器作傳檔的動作。但不管後面有沒有接上另一台機器,都要多空一行,不然離不了線會掛在那邊. x0
|
引用 | 編輯
ccxxx
2005-03-23 01:13 |
1樓
▲ |
Here is the script I used, hope it can help.
#!/bin/sh # # ftp script to send/get file automatically # # define the variables filename1="/path1/filename1" filename2="/path1/filename2" hostname="ftp.domain_name.com" username="username" password="password" # main ftp -n $hostname <<EOF quote USER $username quote PASS $password binary put $filename1 get $filename2 quit EOF x0 |