我的外壳: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!