2012年3月12日 星期一

簡易 Linux FTP upload shell

簡易的FTP 檔案上傳Shell script


於Terminal中,輸入
gvim ftpUpload.sh
並輸入下列內容於此檔案
#!/bin/bash
echo file(s) upload $*;
ftp -v -i -n FTP位址 << FTPIT
user 帳戶 密碼
bin
cd /切換至要放上傳檔案的目錄
mput $*
quit
FTPIT
exit 0
存檔離開,並改變此檔案的屬性
chmod 755 ftpUpload.sh
最後,執行
./ftpUpload.sh file1.txt file2.doc file3.mov

p.s. 後面帶的參數即為要傳送的檔案名,而$*則為儲存所有arg的變數(以空格區隔)

沒有留言:

搜尋此網誌