代码示例如下:

#!/bin/bash
#Linux 环境下使用FTP非交互式批量上传文件

ftp -n << EOF
open FTP服务器的IP地址  # 指定ftp服务器的IP
user FTP用户名 密码  # 指定ftp服务器的用户名和密码
binary # 指定FTP的模式
cd /home/ftp  # 要上传到ftp服务器的目录
lcd /home/files  # 本地Linxu的的目录
prompt  # 关闭mput的上传确认提示
mput file1 file2 file3  # 批量上传文件,若只上传单个文件,改为put即可,get/mget同理;
bye
EOF
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.