Linux下使用shell实现上传linux下某个目录下所有文件到ftp
2016-11-05 22:38
686 查看
首先我们需要搞清楚单个文件怎么上传,把这个单文件上传到ftp上的实现命名为一个:upload_to_ftp_command.sh
之后,需要弄清楚怎么实现遍历一个目录下的所有文件的,把这个遍历某个目录下的文件实现命名为:foeach_directory_and_uploadfile_to_ftp.sh。
upload_to_ftp_command.sh
foeach_directory_and_uploadfile_to_ftp.sh
调用foeach_directory_and_uploadfile_to_ftp.sh:
参考文章:
http://jingyan.baidu.com/article/22fe7ced209c073003617f47.html?st=2&os=0&bd_page_type=1&net_type=2
http://blog.sina.com.cn/s/blog_5ad08c1601013gl2.html
之后,需要弄清楚怎么实现遍历一个目录下的所有文件的,把这个遍历某个目录下的文件实现命名为:foeach_directory_and_uploadfile_to_ftp.sh。
upload_to_ftp_command.sh
#!/bin/bash FTILE_NAME=$1 ftp -n <<- EOF open 100.170.141.26 user jy new.abc$ cd /Temp/a_datang/s1mme1031 bin put $FTILE_NAME bye EOF
foeach_directory_and_uploadfile_to_ftp.sh
#!/bin/bash for file in ./* do if test -f $file then echo $file ' is file' ./upload_to_ftp_command.sh $file fi if test -d $file then echo $file ' is directory' fi done
调用foeach_directory_and_uploadfile_to_ftp.sh:
$ ./foeach_directory_and_uploadfile_to_ftp.sh ./000000_0 is file ./000001_0 is file ./000002_0 is file ./000003_0 is file ./000004_0 is file ./000005_0 is file ./000006_0 is file ./000007_0 is file ./000008_0 is file ./000009_0 is file ./000010_0 is file ./000011_0 is file ./000012_0 is file ./000013_0 is file ./000014_0 is file ./000015_0 is file ./000016_0 is file ./000017_0 is file ./000018_0 is file ./000019_0 is file ./000020_0 is file ./000021_0 is file ./000022_0 is file ./upload_to_ftp_command.sh is file ./foeach_directory_and_uploadfile_to_ftp.sh is file
参考文章:
http://jingyan.baidu.com/article/22fe7ced209c073003617f47.html?st=2&os=0&bd_page_type=1&net_type=2
http://blog.sina.com.cn/s/blog_5ad08c1601013gl2.html
相关文章推荐
- Linux使用Shell脚本实现ftp的自动上传下载
- Linux下使用Shell脚本实现ftp的自动上传下
- Linux下使用Shell脚本向FTP服务器上传或下载一个文件
- 使用.net FtpWebRequest 实现FTP常用功能 上传 下载 获取文件列表 移动 切换目录 改名
- Linux下使用libcurl库实现ftp上传文件
- Linux使用Shell脚本实现ftp的自动上传下载
- Linux下使用Shell脚本实现ftp的自动上传下载的代码小结
- Linux下使用Shell脚本删除一个目录下的所有子目录和文件
- Linux使用Shell脚本实现ftp的自动上传下载
- Linux使用Shell脚本实现ftp的自动上传下载
- Linux下使用Shell脚本实现ftp的自动上传下载的代码小结
- Linux使用Shell脚本实现ftp的自动上传下载(转)
- CentOS中使用Shell脚本实现每天自动备份网站文件和数据库并上传到FTP中
- Linux 利用shell中使用ftp自动下载上传文件
- Linux使用Shell脚本实现ftp的自动上传下载
- CentOS中使用Shell脚本实现每天自动备份网站文件和数据库并上传到FTP中(转)
- 使用.net FtpWebRequest 实现FTP常用功能 上传 下载 获取文件列表 移动 切换目录 改名 .
- Linux使用Shell脚本实现ftp的自动上传下载
- Linux使用Shell脚本实现ftp的自动上传下载
- Linux使用Shell脚本实现ftp的自动上传下载