expect 模拟交互
ftp 上传文件到指定目录下
服务端下载vsftpd
1.服务端下载vsftpd
yum -y install vsftpd
2.配置vsftpd
anon_upload_enable=YES anon_mkdir_write_enable=YES chown_uploads=YES
3 重启vsftpd 关闭防火墙和selinux 修改权限
chmod -R 777 /var/ftp/pub
systemctl restart vsftpd systemctl stop firewalld
setenforce 0
4.客户端下载ftp
yum -y install ftp
5.在客户端写脚本
注意:用expect写脚本需要下载 expect
yum -y install expect
#!/usr/bin/expect spawn ftp 192.168.177.246 expect ":root):" send "anonymous\r" expect "Password:" send "\r" expect "ftp >" send "cd pub\r" expect "ftp >" send "put /tmp/yum.log a.log\r" interact