JIT
中文回答。我在debain系统,写了个.sh文件。但是链接ftp成功,上传0k 最后超时。 ftp -v -n << END open ftp.1fichier
中文回答。我在debain系统,写了个.sh文件。但是链接ftp成功,上传0k 最后超时。 ftp -v -n << END open ftp.1fichier.com user moderator@tutamail.com kjhk897AAAA type binary put $WebBakName bye END 日志: Connected to ftp.1fichier.com. 220-Welcome to 1fichier.com FTP Server. - Look at https://1fichier.com to subscribe. 220-Local time is now 05:14. Server port: 21. 220-This is a private system - No anonymous login 220 You will be disconnected after 15 minutes of inactivity. 331 User moderator@tutamail.com OK. Password required 230 OK. Current directory is / Remote system type is UNIX. Using binary mode to transfer files. 200 TYPE is now 8-bit binary 550 Could not delete hestiacp2025-ams_20250715.tar.gz: No such file or directory local: hestiacp2025-ams_20250720.tar.gz remote: hestiacp2025-ams_20250720.tar.gz 200 PORT command successful 425 Could not open data connection to port 57883: Connection timed out 221-Goodbye. You uploaded 0 and downloaded 0 kbytes. 221 Logout.

从日志来看,FTP上传失败有几个关键问题:

  1. 550错误显示服务器尝试删除旧文件但找不到(可能是权限问题)
  2. 425错误表明数据连接超时(可能是防火墙/被动模式问题)

修改后的脚本应添加被动模式并处理错误:

主要改进:

  1. 添加了passive命令强制使用被动模式
  2. 添加了status命令查看连接状态
  3. 单独处理删除命令的错误(2>/dev/null)
  4. 添加了错误检查($?)
  5. 文件名使用动态日期生成

执行前请确保:

  1. 脚本有执行权限(chmod +x upload.sh)
  2. 文件$WebBakName存在且可读
  3. 服务器防火墙允许FTP被动模式端口(可能需要配置)
Updated files
v1