linux下使用ftp命令上传指定路径下所有文件脚本
#!/bin/bash
HOST="your_ftp_host" # FTP服务器地址
USERNAME="your_username" # FTP登录用户名
PASSWORD="your_password" # FTP登录密码
LOCALDIR="/path/to/local/directory/" # 要上传的本地目录路径
REMOTEDIR="/remote/directory/" # 远程目标目录路径(如果不存在则会自动创建)
cd $LOCALDIR || exit
for file in *; do
if [ -f "$file" ]; then
ftp -in <<EOF
open $HOST
user $USERNAME $PASSWORD
binary
lcd $LOCALDIR
put $file $REMOTEDIR$file
quit
EOF
fi
done