首先我们需要搞清楚单个文件怎么上传,把这个单文件上传到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. 【JAVA】ConcurrentHashMap

    HashTable 写操作时候,Lock全表    源码:  public synchronized V put(K key, V value) {  // Make sure the value i ...

  2. NOI模拟 热身赛T1

    设p(m)的值为m的正因数个数(包括1和m本身)给定n,求满足p(x)=n的最小x. 简直弱到不行了... VW做法: 其实蛮简单的,然而想的时候忽略了指数是不增的 然后你以为做完了吗? 愚蠢的贡献了 ...

  3. gcc 版本降级

    由于刚刚装了ubuntu 16.04,该版本gcc版本为5.4.0太高,很多软件不支持,所以要降版本,可以直接看(三)解决 一.gcc源代码网站 ftp://mirrors.kernel.org/gn ...

  4. MySQL 服务无法启动。服务没有报告任何错误。

    MySQL数据库在升级到5.7版本后,和之前的版本有些不一样,没有data文件夹,我们都知道MySQL数据库文件是保存在data文件夹中的,网上有人说把5.6版本的data文件夹拷贝一个,这种说法听听 ...

  5. python select

    server #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: zengchunyun " ...

  6. [LintCode] Reverse Nodes in k-Group 每k个一组翻转链表

    Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If ...

  7. parentNode,offsetParent

    元素.parentNode : 父节点   只读 属性 当前节点的父级节点 没有兼容性问题 可放心使用 <!DOCTYPE HTML> <html> <head> ...

  8. 使用Font Awesome替换你的网站图标

    http://fortawesome.github.io/Font-Awesome/whats-new/ 使用Font Awesome替换你的网站图标 ******************IE7BUG ...

  9. spring security动态管理资源结合自定义登录页面

    如果想将动态管理资源与自定义登录页面一起使用,最简单的办法就是在数据库中将登录页面对应的权限设置为IS_AUTHENTICATED_ANONYMOUSLY. 因此在数据库中添加一条资源信息. INSE ...

  10. Bash中各种以$开头的特殊变量的含义

    $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行的命令的结束代码(返回值) $- 使用Set命令设定的Flag一览 $* 所有参 ...