首先我们需要搞清楚单个文件怎么上传,把这个单文件上传到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. [Leetcode] Scramble String

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...

  2. BZOJ2844: albus就是要第一个出场

    Description 已知一个长度为n的正整数序列A(下标从1开始), 令 S = { x | 1 <= x <= n }, S 的幂集2^S定义为S 所有子集构成的集合. 定义映射 f ...

  3. 纪念逝去的岁月——C/C++字符串回文

    判断字符串是否是回文: 1. 输入:hello world dlrow olleh 输出:1 2. 输入:nihao hello 输出:0 代码 #include <stdio.h> #i ...

  4. 分模块创建maven项目(二)

    1.新建Parent项目,MavenProject 2.新建子模块项目,MavenProject 右击项目名 --> NEW --> other 结果,在parent上运行会打出两个包,一 ...

  5. 李洪强iOS经典面试题132-版本控制

    面试过程中,可能会问及一些关于版本控制的问题,理解下SVN和Git的原理,记住常用命令即可. SVN SVN 是集中式源代码管理工具 概念: 1> Repository 代码仓库,保存代码的仓库 ...

  6. 如何给Sublime安装插件

    第一步:点击链接http://sublime.wbond.net/Package%20Control.sublime-package下载Package Control. 第二步:点击打开Sublime ...

  7. php继承后构造函数的特性

    在5.x版本的php中: 如果父类有构造函数,它的子类也有构造函数,那么在运行子类时就“不会执行父类的构造函数”. 要想执行父类的构造函数,需要在子类的构造函数中加上: parent::__const ...

  8. ACM Steps 2.1.4

    Largest prime factor   Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...

  9. HTTPS协议简介

    一.HTTPS简介 百度已经于近日上线了全站 HTTPS 的安全搜索,默认会将 HTTP 请求跳转成 HTTPS.本文重点介绍 HTTPS 协议, 并简单介绍部署全站 HTTPS 的意义. HTTPS ...

  10. Linux下一些有用的指令

    1.   安装源代码包用到的configure 这用来定位安装位置. 用法: ./configure -prefix=<安装目录>,  前提是文件中有configure执行文件.