1,上传单个文件的脚本: 
 
#!/bin/bash
# edit by www.jb200.com
FTP_SERVER=192.168.8.10 
USER="loglogic" 
PASSWORD="log1234" 
FTP_PATH="/zhu" 
LOCAL_PATH="/home/test"
if test -f /$LOCAL_PATH/login.sh 
then 
# file exits, so upload and print a message. 
ftp -i -n $FTP_SERVER < user $USER $PASSWORD 
passive 
binary 
cd /$FTP_PATH 
lcd /$LOCAL_PATH
put login.sh # file name 
AUTO_PATH 
echo "Done!" 
else 
# file doesn't exit, so we print a message and exit. 
echo "This file doesn't exit." 
exit 
fi
2,上传多个文件的shell/ target=_blank class=infotextkey>shell脚本: 
 
#!/bin/bash
#! edit by www.jb200.com
# This script is for upload all files as same directory to FTP Server. 
FTP_SERVER=192.168.8.10
USER="loglogic" 
PWD="log1234" 
FTP_PATH="/zhu" 
LOCAL_PATH="/home/test"
ftp -i -n $FTP_SERVER < user $USER $PWD 
passive 
binary 
cd /$FTP_PATH
lcd /$LOCAL_PATH 
mput * 
AUTO_PATH
知识点:
以上脚本中用到了mput命令,这个值得关注下。
另外,在linux下上传文件,可以考虑lftp命令,更快更好用。
有关lftp命令的用法,可以参考文章: