文章详情页
Linux实现文件上传ftp服务器脚本代码
浏览:188日期:2023-03-25 09:40:15
工作期间,每次将文件上传至ftp服务器时,均需要手工输入ip、用户名、密码等,因此,考虑编写脚本完成文件的上传任务。具体的脚本sync.sh如下:
#!/bin/bash source ~/.bashrc # 模拟进入ftp命令行模式,其中EOF表示退出标记符 ftp -niv <<- EOF # 根据ftp的ip地址与端口号,连接ftp服务器 open ip port # 输入用户名与密码 user userName password # 以bin模式进行传输,与ASCII模式有区别,使用bin模块能够防止乱码问题 bin # 上传文件 get $1 # 结束 bye #退出 EOF
然后将该脚本sync.sh加入环境变量,每次只需执行 sync.sh filename即可,具体的执行过程如下:
Connected to *.*.*.*. 220 Microsoft FTP Service 331 Password required for userName. 230 User logged in. Remote system type is Windows_NT. 200 Type set to I. local: filename remote: filename 200 PORT command successful. 125 Data connection already open; Transfer starting. 226 Transfer complete. 112089125 bytes received in 44.62 secs (2453.3 kB/s) 221 Goodbye.
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
标签:
FTP
相关文章:
1. linux中如何修改打开文件数限制open file limit2. linux free命令以及系统内存占用过高的处理方式3. Linux中如何查看usb设备信息4. linux proftpd-1.3.4c安装配置实例5. linux系统之如何禁用usb口6. Linux系统中.bash_profile文件详解7. 在Linux中如何列出和删除Iptables防火墙规则8. Win11安装VMware Workstation Pro,Centos,Xshell,Xftp图文教程(Linux学习必备)9. Linux一键安装xdd plus机器人10. Linux系统 第2节 虚拟机中安装Kali系统
排行榜
