加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在BASH脚本中上传FTP

发布时间:2020-12-15 18:36:45 所属栏目:安全 来源:网络整理
导读:我需要将目录/ home / test的全部内容上传到我的ftp服务器,在特定的文件夹中. 然后我将通过cron每小时安排脚本. 任何例子? NB.考虑到我在Netgear ReadyNAS Duo(debian盒子)上,我无法安装lftp或类似物,只能使用标准命令:) 在线找到这个有质量文档的bash脚本
我需要将目录/ home / test的全部内容上传到我的ftp服务器,在特定的文件夹中.
然后我将通过cron每小时安排脚本.
任何例子?

NB.考虑到我在Netgear ReadyNAS Duo(debian盒子)上,我无法安装lftp或类似物,只能使用标准命令:)

在线找到这个有质量文档的bash脚本:
#!/bin/bash

HOST=ftp.server.com  #This is the FTP servers host or IP address.
USER=ftpuser             #This is the FTP user that has access to the server.
PASS=password          #This is the password for the FTP user.

# Call 1. Uses the ftp command with the -inv switches. 
#-i turns off interactive prompting. 
#-n Restrains FTP from attempting the auto-login feature. 
#-v enables verbose and progress. 

ftp -inv $HOST << EOF

# Call 2. Here the login credentials are supplied by calling the variables.

user $USER $PASS

# Call 3. Here you will change to the directory where you want to put or get
cd /path/to/file

# Call4.  Here you will tell FTP to put or get the file.
put test.txt

# End FTP Connection
bye

EOF

配置并保存.sh脚本后,使其可执行:

chmod x ftpscript.sh

最后,配置你的cronjob

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读