首先我们需要搞清楚单个文件怎么上传,把这个单文件上传到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. NOIP 2005 等价表达式 (TYVJ P1060)

    做题记录: 2016-08-10 23:35:09 背景 NOIP2005 提高组 第四道 描述 明明进了中学之后,学到了代数表达式.有一天,他碰到一个很麻烦的选择题.这个题目的题干中首先给出了一个代 ...

  2. 简单 常用的git命令

    常用的git命令 git pull  获取最新 git add . 提交所有 git commit  -m “我的注释” git status 查看状态 git push origin master ...

  3. Linux 下安装mysql 链接库

    1.mysql 客户端 开发 链接库 1.1)CentOS yum install mysql-devel

  4. Linux_JDK安装

    一.下载linux版本的jdk压缩包(这里安装jdk1.7版本,子版本随意,选择*.tar.gz文件下载) 下载目录:http://www.oracle.com/technetwork/java/ja ...

  5. mysql字符乱码

    解决mysql字符乱码思路: mysql服务器字符集 mysql客户端字符集 系统字符集 生产环境改字符集: 1.导出表结构到 scam.sql文件中 2.更改scam.sql文件中的字符集为想要的字 ...

  6. 为什么会出现Python Exception <class 'gdb.MemoryError'> Cannot access memory at address 问题?

    问题描述:        把列表listview写入notebook里. 在main函数中, win = create_and_set_a_window(); book = gtk_notebook_ ...

  7. 20145337 《Java程序设计》第九周学习总结

    20145337 <Java程序设计>第九周学习总结 教材学习内容总结 数据库本身是个独立运行的应用程序 撰写应用程序是利用通信协议对数据库进行指令交换,以进行数据的增删查找 JDBC可以 ...

  8. TFTP服务

    $ mkdir /tftpboot$ cp exynos4412-fs4412.dtb uImage /tftpboot$ sudo chmod 777 tftpboot(~下)$ sudo chmo ...

  9. 【转】CSRF攻击的应对之道

    CSRF 背景与介绍CSRF(Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,它在 2007 年曾被列为互联网 20 大安全隐患之一.其他安全隐患,比如 ...

  10. 【iCore3 双核心板_FPGA】例程一:认识FPGA

    实验指导书及代码包下载: http://pan.baidu.com/s/1kUa05FL iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...