我的外殼:bin/ksh
我的系統:
Linux 2.6.18-406.el5 #1 SMP Fri May 1 10:37:57 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux
我的腳本:
ftp -divn XXX.XXX.XX0 << EOF!
user user pass
cd /home/dir1/dir2/dir3/
lcd /home/dir34/dir45
get filename
bye
EOF!
我的問題:我想自動化這個過程。我不想寫所有的程式碼行,我想要的是只寫最後的目錄“input”,目錄是“output”和檔案名稱。
例如:我想將 FILE1.txt 從 cd /home/dir1/dir2/dir3/dirdata 發送到 /home/dir34/dir45/dirfinal 我想執行腳本並且只在控制台中寫入:
dirdata
dirfinal
FILE1.txt
答案1
magic_script dirdata dirfinal file1.txt
$0 is the script_name (magic_script)
$1 first argument dirdata
$2 second argument dirfinal
$3 third argument file1.txt
ftp -divn XXX.XXX.XX0 << EOF!
user user pass
cd /home/dir1/dir2/dir3/"$1"
lcd/home/dir11/dir22/dir33/"$2"
get "$3"
bye
EOF!