zoukankan      html  css  js  c++  java
  • shell脚本之不同系统上ftp交互使用

    场景:当公司将有文件要自动将ubuntu系统的文件要上传到windows上面,或者windows上的文件要下载到ubuntu上面,尤其是像什么日志啊,编译结果啊,测试结果啊等等,做个备份或者做分析处理等。

    下面是shell脚本模板:

    !/bin/bash

    #上传文件

    ftp -v  -niv  <<EOF                                  #EOF附件没有空格,不然会报错

    open  192.168.1.1                                    #FTP服务器IP

    user  ming   123@@qwe                           #用户名  密码

    passive                                                    #被动模式 active 主动模式

    binary                                                      # 二进制传输

    hash                                                         #打印

    cd  /localdisk/                                           #ftp上传文件目录

    lcd   /home/                                         #本地要上传文件的目录

    prompt                                                    #切换交互式提示

    mput    *                                                   #多文件上传       

    put   ming.sh                                           #单文件上传put

    close                                                       #关闭连接

    bye                                                           #退出

    EOF

    echo    "commit to ftp successfully"

    +++++++++++++++++++++++++++++++++++

    #下载文件

    ftp -v  -niv  <<EOF

    open 192.168.1.1                                    #FTP服务器IP

    user ming   123@@qwe                           #用户名  密码

    passive                                                    #被动模式 active 主动模式

    binary                                                    # 二进制传输

    cd     /localdisk/data                               #ftp上传文件目录

    lcd    /home/                                        #本地要上传文件的目录

    hash                                                     #打印

    prompt off                                             #切换交互式提示

    mget   *                                               #多文件下载

    close                                                  #关闭连接

    bye                                                   #退出

    EOF

    echo     "download from ftp successfully"

  • 相关阅读:
    LeetCode59 Spiral Matrix II
    LeetCode58 Length of Last Word
    LeetCode54 Spiral Matrix
    LeetCode63 Unique Paths II
    LeetCode62 Unique Paths
    LeetCode55 Jump Game
    网易2017年校招笔试题 最大的奇约数
    Codeforces Round #119 (Div. 2)
    Codeforces Round #118 (Div. 2)
    2016 MIPT Pre-Finals Workshop Taiwan NTU Contest
  • 原文地址:https://www.cnblogs.com/ming369/p/10731779.html
Copyright © 2011-2022 走看看