首先我们需要搞清楚单个文件怎么上传,把这个单文件上传到ftp上的实现命名为一个:upload_to_ftp_command.sh

之后,需要弄清楚怎么实现遍历一个目录下的所有文件的,把这个遍历某个目录下的文件实现命名为:foeach_directory_and_uploadfile_to_ftp.sh。

upload_to_ftp_command.sh

#!/bin/bash
FTILE_NAME=$
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&amp;net_type=2

http://blog.sina.com.cn/s/blog_5ad08c1601013gl2.html

Linux下使用shell实现上传linux下某个目录下所有文件到ftp的更多相关文章

  1. 图片上传至/target/upload目录下后,通过ip:port/upload/无法访问

    做以下配置即可 @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { try { registry ...

  2. Linux下远程备份、上传工程,重启服务器

    Linux下远程备份.上传工程,重启服务器 Linux服务器实现远程,原项目的备份.删除,新项目上传,以及远程重启服务器!分成一个主shell调用三个shell文件步骤完成.mainsh.sh一次按顺 ...

  3. linux下通过命令行上传文件到百度网盘

    一.环境: centos release 6.9 python 2.7.13 二.安装工具bypy sudo pip install bypy 三.使用bypy 3.1 授权 [root@ineedl ...

  4. linux下 利用 rz 命令上传文件

    1. 如何安装? 1)编译安装  root 账号登陆后,依次执行以下命令: # cd /tmp # wget http://www.ohse.de/uwe/releases/lrzsz-0.12.20 ...

  5. Linux 文件上传Linux服务器

    进入命令行 在图形化桌面出现之前,与Unix系统进行交互的唯一方式就是借助由shell所提供的文本命令行界面(command line interface,CLI).CLI只能接受文本输入,也只能显示 ...

  6. 在linux命令行利用SecureCRT上传下载文件

    一般来说,linux服务器大多是通过ssh客户端来进行远程的登陆和管理的,使用ssh登陆linux主机以后,如何能够快速的和本地机器进行文件的交互呢,也就是上传和下载文件到服务器和本地?与ssh有关的 ...

  7. 在windows和linux之间用SecureCRT来上传和下载文件

    SecureCRT可以使用linux下的zmodem协议来快速的传送文件,使用非常方便.具体步骤:一.在使用SecureCRT上传下载之前需要给服务器安装lrzsz:A:CentOS中使用yum安装即 ...

  8. Debian下自动备份文件并上传到远程FTP服务器且删除指定日期前的备份Shell脚本

    说明:  1.备份目录/home/osyunwei下面所有的文件到/home/osyunweibak里面,并且保存为osyunwei20120701.tar.gz的压缩文件格式(2012_07_01是 ...

  9. 1、win10下连接本地系统上的Linux操作系统(分别以Nat方式和桥接模式实现)

    1.win10下连接本地系统上的Linux操作系统(分别以Nat方式和桥接模式实现) 一.准备知识:win10下打开Administrator的方式 在win10操作系统中,Administrator ...

随机推荐

  1. [深入浅出Windows 10]应用实战:Bing在线壁纸

    本章介绍一个使用Bing搜索引擎背景图接口实现的一个应用——Bing在线壁纸,讲解如何使用网络的接口来实现一个壁纸下载,壁纸列表展示和网络请求封装的内容.通过该例子我们可以学习到如何使用网络编程的知识 ...

  2. BZOJ4027: [HEOI2015]兔子与樱花 贪心

    觉得是贪心,但是一开始不太肯定...然后就A了 一个点对它的父亲的贡献就是自己的权值加儿子的个数 #include<bits/stdc++.h> using namespace std; ...

  3. ios8 tableView设置滑动删除时 显示多个按钮

      ** *  tableView:editActionsForRowAtIndexPath:     //设置滑动删除时显示多个按钮 *  UITableViewRowAction          ...

  4. Bootstrap_让Bootstrap轮播插件carousel支持左右滑动手势的三种方法

    Bootstrap 的 carousel.js 插件并没有支持手势. 3种解决方案 : jQuery Mobile (http://jquerymobile.com/download/) $(&quo ...

  5. Windows Phone Foreground Toast

    Basically ToastPrompt is an UI component that derives from the Coding4Fun toolkit's abstract PopUp&l ...

  6. 符号三角形——F

    F. 符号三角形 Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO format:      Java class name: 符号 ...

  7. Java 多继承

    浅浅地上了几天 Java 的课程,然后怎么也想不明白:Java 不支持多继承有和接口到底是什么样的关系? 一只牛的故事. // 叫的抽象基类 abstract class call{ } // 跑的抽 ...

  8. c# 哈希表跟函数

    一.哈希表集合 先进后出,一个一个赋值,但只能一起取值. 1.哈希表的建立.赋值以及读取. 2.利用枚举类型打印出集合中的Key值和Value值. 二.函数 函数:能够独立完成某项功能的模块. 函数四 ...

  9. Javascript 中的一些关于时间的操作【转】

    1.时间对象和一些简单操作函数 var myDate = new Date(); myDate.getYear();       //获取当前年份(2位) myDate.getFullYear(); ...

  10. 了解C++默认编写并调用哪些函数

    概念:编译器可以暗自为class创建default构造函数.copy构造函数.copy assignmengt构造函数,以及析构函数. 比如你写下:struct Node { }; 这就好像你写下这样 ...