智慧中台智慧管理平台

一. Java代码

package com.abc;


import java.io.*;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

import com.alibaba.fastjson.JSONObject;


public class controller {
    //static String filepath = "D:\\test01\\";

    public static Map<String, String> m = new HashMap<>();  //静态代码块 !
    public static Map<String,String> m2=new HashMap<>();

    static {
        // value写成 Json样式,方便存到JSONObject中!
        //  ,    Value=“{  4.abId=统一能力编码   5.abName-能力名称&  abPeople-能力专员 abTypeM-能力类型(月表) 6.abTypeD-能力类型(SDK) 8.serName-服务名称&  10.ownerName-能力提供方名称 11.abOwnerId-能力提供方编码  12.consumerName-能力使用方名称 13.consumerId-能力使用方编码  14.consumerProject-能力使用方应用名称 15.consumerProjectId能力使用方应用编码
        m.put("001", "{ \"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"重庆公司\",\"consumerId\":\"230\",\"consumerProject\":\"重庆移动基于隐私多方安全计算平台\"}");
        m.put("1","   {\"a\":\"b\"}   ");
        m.put("002", "{\"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"中移(上海)产业研究院\",\"consumerId\":\"034\",\"consumerProject\":\"基于联邦学习技术的运营商联合反欺诈模型研究及应用\"}");
        m.put("003", "{\"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"集成公司\",\"consumerId\":\"036\",\"consumerProject\":\"众邦银行信用风控项目\"}");
        m.put("004", "{\"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"信息技术中心\",\"consumerId\":\"006\",\"consumerProject\":\"浦发银行信用风控项目\"}");
        m.put("005", "{\"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"信息技术中心\",\"consumerId\":\"006\",\"consumerProject\":\"试用多方安全计算,发掘与区块链的结合点\"}");
        m.put("006", "{\"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"天津公司\",\"consumerId\":\"220\",\"consumerProject\":\"联邦学习天津试点项目\"}");
        m.put("007", "{\"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"江西公司\",\"consumerId\":\"791\",\"consumerProject\":\"江西公司数据中台2022年4月相关能力引入申请\"}");
        m.put("008", "{\"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"互联网公司\",\"consumerId\":\"230\",\"consumerProject\":\"5G消息不良信息管控系统申请使用多方安全计算能力\"}");
        m.put("009", "{\"abId\":\"A200600106\",\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"研究院\",\"consumerId\":\"230\",\"consumerProject\":\"基于联邦学习技术的运营商联合反欺诈模型研究及应用\"}");

        //月表的Map
        m2.put("A200600106", "{\"abName\":\"多方安全计算能力\",\"abPeople\":\"848\",\"abTypeM\":\"0\",\"abTypeD\":\"SDK\",\"serName\":\"Paas\",\"ownerName\":\"信息技术中心\",\"abOwnerId\":\"006\",\"consumerName\":\"重庆公司\",\"consumerId\":\"230\",\"consumerProject\":\"重庆移动基于隐私多方安全计算平台\"}");

    }
    //能力编码(key) 和能力名称对应 !

    Map<String, String> fileMap = new HashMap<>(); //4.1 /2/3 文件名+内容
    Map<String, String> fileMapSDK = new HashMap<>(); //4.6 文件名+内容

    public String testMonth(String filepath) {
        // 制作文件名和文件内容到filemap
        // 三个月表的数据各自作为fileMap的一个键值对
        for (Map.Entry<String, String> k : m2.entrySet()) {  //每一轮循环就是Map的一个键值对 ,也是Set的一个元素 !

            //每一轮创建三个StringBuffer
            StringBuffer stringBuffer1 = new StringBuffer(); //4.1 txt中内容
            StringBuffer stringBuffer2 = new StringBuffer(); //4.2 txt中内容
            StringBuffer stringBuffer3 = new StringBuffer(); //4.3 txt中内容

            //遍历出数据中的key和value
            System.out.print("key=" + k.getKey() + ", value=" + k.getValue());
            System.out.println("\n");


            //获取上个月的月份
            String lastMonth = getLastMonth();

            //将每一轮(一个键值对即一行数据)的value内容(多个键值对)到JSONObject
            JSONObject abJson = JSONObject.parseObject(k.getValue());



            //4.1 效能评估指标--月表文件
            if (stringBuffer1.length() != 0) {    //StringBuffer 不为0则加换行符
                stringBuffer1.append("\r\n");   //  \r是return回车,  \n是new换行,  \r\n=换行
            }
            //月份
            stringBuffer1.append(lastMonth + "€€");
            //能力ID
            stringBuffer1.append(k.getKey() + "€€"); //同一轮内的key、value都不变!
            //能力名称
            stringBuffer1.append(abJson.get("abName").toString() + "€€");
            //领域-市场
            stringBuffer1.append("市场" + "€€");
            //效能类型
            stringBuffer1.append("提智" + "€€");
            //效能值-0
            stringBuffer1.append(0);

            //文件名
            String fileMapKey = "M_" + "006" + "_" + "F10001" + "_" + "006" + "_" + abJson.get("abPeople").toString() + "_" + lastMonth + "_" + "00";


            if (null == fileMap.get(fileMapKey)) {  // 如果fileMapKey不存在,则直接put
                fileMap.put(fileMapKey, stringBuffer1.toString()); //key是文件名,  value是内容
            } else {  //如果fileMapKey已经存在了, 则put时要加上之前的value ! 月表文件一个月只有一个,文件名不会重复!
                fileMap.put(fileMapKey, fileMap.get(fileMapKey) + "\r\n" + stringBuffer1.toString());
            }


            //4.2效能评估指标--月表文件
            if (stringBuffer2.length() != 0) {
                stringBuffer2.append("\r\n");
            }
            //月份
            stringBuffer2.append(lastMonth + "€€");
            //能力ID
            stringBuffer2.append(k.getKey() + "€€"); //同一轮内的key、value都不变!
            //能力名称
            stringBuffer2.append(abJson.get("abName").toString() + "€€");
            //领域-市场
            stringBuffer2.append("市场" + "€€");
            //效能类型
            stringBuffer2.append("提效" + "€€");
            //效能度量项
            stringBuffer2.append("满意度" + "€€");
            //效能度量项百分比
            stringBuffer2.append(85);

            //文件名
            fileMapKey = "M_" + "006" + "_" + "F10002" + "_" + "006" + "_" + abJson.get("abPeople").toString() + "_" + lastMonth + "_" + "00";

            if (null == fileMap.get(fileMapKey)) {  // 如果fileMapKey不存在,则直接put
                fileMap.put(fileMapKey, stringBuffer2.toString()); //key是文件名,value是内容
            } else {  //如果fileMapKey已经存在了, 则put时要加上之前的value
                fileMap.put(fileMapKey, fileMap.get(fileMapKey) + "\r\n" + stringBuffer2);
            }


            //4.3效能评估指标--月表文件
            if (stringBuffer3.length() != 0) { //若是追加数据 则先换行
                stringBuffer3.append("\r\n");
            }
            //月份
            stringBuffer3.append(lastMonth + "€€");
            //能力ID
            stringBuffer3.append(k.getKey() + "€€"); //同一轮内的key、value都不变!
            //能力名称
            stringBuffer3.append(abJson.get("abName").toString() + "€€");
            //能力类型
            stringBuffer3.append(abJson.get("abTypeM").toString() + "€€");
            //能力漏洞数
            stringBuffer3.append(0 + "€€");
            //能力安全事件数
            stringBuffer3.append(0 + "€€");
            //能力需要保护数的服务数   ? ?
            stringBuffer3.append(0 + "€€");
            //需要保护但未保护的服务树

            stringBuffer3.append(0 + "€€");
            //未按规范进行敏感数据保护服务数
            stringBuffer3.append(0 + "€€");
            //故障次数
            stringBuffer3.append(0 + "€€");
            //故障处理时长
            stringBuffer3.append(0 + "€€");
            //停服时长
            stringBuffer3.append(0 + "€€");
            //连续无故障时长
            long aTime = getDistanceDay();  //  20210207 ? ? ?


            //log.info("aTime" + aTime);

            stringBuffer3.append(aTime);
            //文件名
            fileMapKey = "M_" + "006" + "_" + "F10003" + "_" + "006" + "_" + abJson.get("abPeople").toString() + "_" + lastMonth + "_" + "00";
            if (null == fileMap.get(fileMapKey)) {
                fileMap.put(fileMapKey, stringBuffer3.toString()); //像fileMap存入key(文件名) 和value(内容)
            } else {
                fileMap.put(fileMapKey, fileMap.get(fileMapKey) + "\r\n" + stringBuffer3.toString());
            }

            //遍历出key和value
            // System.out.println("key=" + k.getKey() + ", value=" + k.getValue());

        }




        //写入文件
        for (Map.Entry<String, String> k : fileMap.entrySet()) {  //每一轮fileMapKey(文件名)一样,以此达到  一个专员一个文件的效果
            System.out.println("Key = " + k.getKey() + ", Value = " + k.getValue());

            try {
                // 建立File目录
                File filemkdir = new File(filepath + getlastDay());
                if (!filemkdir.exists() && !filemkdir.isDirectory()) {
                    System.out.println("//directory is not exists");
                    filemkdir.mkdir(); //创建由此抽象路径名命名的目录。
                    System.out.println(filemkdir.getAbsoluteFile().toString());

                }

                // 开始写入txt文件! fileMapKey是txt文件名     getyesterday() + "/"
                File file = new File(filepath + getlastDay() + "/" + k.getKey() + ".txt"); // getkey就是文件名
                if (!file.exists()) {
                    file.createNewFile(); //当且仅当具有该名称的文件尚不存在时,创建一个由该抽象路径名命名的新的空文件。
                }
                FileWriter fw = new FileWriter(file.getAbsoluteFile()); //
                BufferedWriter bw = new BufferedWriter(fw);
                bw.write(k.getValue()); //写入文件内容!filemap的value !
                bw.flush();
                bw.close();

                //用file1 读取file
                File file1 = new File(filepath + getlastDay() + "/" + k.getKey() + ".txt");
                long timestamp = file1.lastModified(); //最后修改的时间,返回总毫秒数
                SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
                String formateDate = sf.format(new Date(timestamp)); //获得最后修改的时间用于CHK文件


                //写入CHK文件     getyesterday() + "/"
                String fileCHK = k.getKey() + ".txt" + "\t" + k.getKey() + ".CHK" + "\t" + formateDate + "\t" + file1.length() + "\t" + getLineNumber(file1) + "\t";
                File file2 = new File(filepath + getlastDay() + "/" + k.getKey() + ".CHK");
                if (!file2.exists()) {
                    file2.createNewFile();
                }
                FileWriter fw2 = new FileWriter(file2.getAbsoluteFile());
                BufferedWriter bw2 = new BufferedWriter(fw2); //包装流
                bw2.write(fileCHK);
                bw2.close();


            } catch (IOException e) {
                e.printStackTrace();
            }

        }
        return "月文件生成完毕";
    }

    public String testSDK(String filepath) {
        for (Map.Entry<String, String> k : m.entrySet()) {

            StringBuffer stringBuffer4 = new StringBuffer(); //4.6 内容

            //遍历出数据中的key和value
            System.out.print("key=" + k.getKey() + ",  value=" + k.getValue());
            System.out.println("\n");

            //获取昨天的日期 (yyyyMMdd)
            String lastDay = getlastDay();

            //存能力编码对应的内容到JSONObject
            JSONObject abJson = JSONObject.parseObject(k.getValue());

            //4.6效能评估指标--SDK
            if (stringBuffer4.length() != 0) { //若是追加数据 则先换行
                stringBuffer4.append("\r\n");
            }
            //1.日期- yyyyMMdd
            stringBuffer4.append(lastDay + "€€");
            //2.统一场景编码    ?
            stringBuffer4.append(0 + "€€");
            //3.场景名称    ?
            stringBuffer4.append("" + "€€");
            //4.统一能力编码
            stringBuffer4.append(abJson.get("abId").toString() + "€€");
            //5.能力名称-
            stringBuffer4.append(abJson.get("abName").toString() + "€€");
            //6.能力类型 -SDK
            stringBuffer4.append(abJson.get("abTypeD").toString() + "€€");
            //7.统一服务编码    ?
            stringBuffer4.append("" + "€€");
            //8.服务名称
            stringBuffer4.append(abJson.get("serName").toString() + "€€");
            //9.本地服务编码    ?
            stringBuffer4.append("" + "€€");
            //10.能力提供方名称
            stringBuffer4.append(abJson.get("ownerName").toString() + "€€");
            //11.能力提供方编码- 006
            stringBuffer4.append(abJson.get("abOwnerId").toString() + "€€");
            //12.能力使用方名称
            stringBuffer4.append(abJson.get("consumerName").toString() + "€€");
            //13.能力使用方编码    ?
            stringBuffer4.append(abJson.get("consumerId").toString() + "€€");
            //14.能力使用方应用名称
            stringBuffer4.append(abJson.get("consumerProject").toString() + "€€");
            //15.能力使用方应用编码
            stringBuffer4.append(0+ "€€");
            //16.内外部系统
            stringBuffer4.append("内部" + "€€");
            //17.能力调用量    0
            stringBuffer4.append(0 + "€€");
            //18.能力调用成功量    0
            stringBuffer4.append(0 + "€€");
            //19.能力调用耗时    0
            stringBuffer4.append(0 + "€€");
            //20.账号总个数    0
            stringBuffer4.append(0 + "€€");
            //21.事件采集数    0
            stringBuffer4.append(0 + "€€");
            //22.工单采集数    0
            stringBuffer4.append(0);


            //文件名
            //日文件需要重传序号自增,除17日从1开始外,其他日期从0开始
            String num = null;
            String yesterday=getlastDay();
            if (yesterday.lastIndexOf("1") == 6 && yesterday.lastIndexOf("7") == 7) {
                num="01";
            } else {
                num="00";
            }


            String fileMapSDKKey = "D_" + "006" + "_" + "F10006" + "_" + "006" + "_" + abJson.get("abPeople").toString() + "_" + lastDay + "_" + num;
            if (null == fileMapSDK.get(fileMapSDKKey)) {
                fileMapSDK.put(fileMapSDKKey, stringBuffer4.toString()); //存入key为文件名, value为内容
            } else {  //Map的Key无序不可重复!必须将之前的value也一起put,否则会被覆盖
                fileMapSDK.put(fileMapSDKKey, fileMapSDK.get(fileMapSDKKey) + "\r\n" + stringBuffer4.toString());
            }


        }

        //写入文件
        for (Map.Entry<String, String> k : fileMapSDK.entrySet()) {  //每一轮fileMapSDKKey一样,以此达到  一个专员一个文件的效果(不同专员会导致fileMapSDKKey即文件名不一样)
            System.out.println("Key = " + k.getKey() + ", Value = " + k.getValue());

            try {
                // 建立File目录
                File filemkdir = new File(filepath + getlastDay());
                if (!filemkdir.exists() && !filemkdir.isDirectory()) { //如果目录已经存在则不需要创建
                    System.out.println("//不存在");
                    filemkdir.mkdir(); //创建由此抽象路径名命名的目录。
                    System.out.println("目录的路径:" + filemkdir.getAbsoluteFile().toString());
                }

                // 开始写入txt文件! fileMapSDKKey是txt文件名     getyesterday() + "/"
                File file = new File(filepath + getlastDay() + "/" + k.getKey() + ".txt");
                if (!file.exists()) {
                    file.createNewFile(); //当且在仅当具有该名称的文件尚不存时,创建一个由该抽象路径名命名的新的空文件。
                }
                FileWriter fw = new FileWriter(file.getAbsoluteFile()); //这里没有true追加! 每写入一次都会覆盖之前的。 相同key的内容都在一个Stringbuffer中!
                BufferedWriter bw = new BufferedWriter(fw);//包装流
                bw.write(k.getValue()); //使用包装流将内容 写入文件file
                bw.flush();
                bw.close();

                //用file1 读取file
                File file1 = new File(filepath + getlastDay() + "/" + k.getKey() + ".txt");
                long timestamp = file1.lastModified(); //最后修改的时间,返回总的毫秒数
                SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
                String formateDate = sf.format(new Date(timestamp)); //获得最后修改的时间用于CHK文件


                //写入CHK文件     getyesterday() + "/"
                String fileCHK = k.getKey() + ".txt" + "\t" + k.getKey() + ".CHK" + "\t" + formateDate + "\t" + file1.length() + "\t" + getLineNumber(file1) + "\t";
                File file2 = new File(filepath + getlastDay() + "/" + k.getKey() + ".CHK");
                if (!file2.exists()) {
                    file2.createNewFile();
                }
                FileWriter fw2 = new FileWriter(file2.getAbsoluteFile());
                BufferedWriter bw2 = new BufferedWriter(fw2); //包装流
                bw2.write(fileCHK);
                bw2.close();


            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return "SDK文件生成完毕";
    }


//返回重传序号
//    private static int getNum(String filepath){
//        File filemkdir = new File(filepath + getlastDay());
//        if (!filemkdir.exists() && !filemkdir.isDirectory()) { //如果目录已经存在则不需要创建
//
//     }else{ //不存在则直接从0开始
//            if()
//
//        }
//
//
//
//        return 0;
//    }


    //获取昨天的日期(yyyyMMdd)
    private static String getlastDay() {
        Date now = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(now);
        calendar.add(Calendar.DATE, -1);      //移动日历中的日期
        String lastDay = sf.format(calendar.getTime()); //格式化
        return lastDay;
    }




    //获取上个月的时间  (yyyyMM)
    public static String getLastMonth() {
        Date now = new Date(); //获取当前时间对象
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMM"); //建立格式

        Calendar calendar = Calendar.getInstance(); //创建一个日历
        calendar.setTime(now); //将日历定位到当前时间
        calendar.add(Calendar.MONTH, -1);  //使月份-1
        String lastMonth = sf.format(calendar.getTime()); //格式化
        return lastMonth;
    }


    //获取一个月前的今天的时间  (yyyyMMdd)
    public static String getLastMonthDay() {
        Date now = new Date(); //获取当前时间对象
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd"); //建立格式

        Calendar calendar = Calendar.getInstance(); //创建一个日历
        calendar.setTime(now); //将日历定位到当前时间
        calendar.add(Calendar.MONTH, -1);  //使月份-1
        String lastMonthDay = sf.format(calendar.getTime()); //格式化
        return lastMonthDay;
    }


    //获取上个月1号到月底即上个月的最后一天(即前一天)的天数
    public static long getDistanceDay(){
        SimpleDateFormat f=new SimpleDateFormat("yyyyMMdd");
        //获取上个月第一天
        Calendar lastM=Calendar.getInstance();
        lastM.add(Calendar.MONTH,-1); //设置为上个月
        lastM.set(Calendar.DAY_OF_MONTH,1); //设置为第一天
        String starttime = f.format(lastM.getTime());
        System.out.println("strattime:"+starttime);

        //前一天的天数yyyyMMdd
        String endtime = getlastDay();
        System.out.println("endtime"+endtime);
        long distanceDays = getDistanceDays(starttime, endtime);
        return distanceDays;
    }

    //求出两个时间之间的差
    public static long getDistanceDays(String starttime, String endtime) {
        DateFormat df = new SimpleDateFormat("yyyyMMdd");
        Date one;
        Date two;
        long days = 0;
        try {
            one = df.parse(starttime);
            two = df.parse(endtime);
            long time1 = one.getTime(); //获取自1970至今的总毫秒数
            long time2 = two.getTime();
            long diff;
            if (time1 < time2) {
                diff = time2 - time1;
            } else {
                diff = time1 - time2;
            }
            days = diff / (1000 * 60 * 60 * 24); //由相差秒数算出相差天数
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return days;//返回相差多少天
    }

    //求出txt文件中内容有多少行
    public static long getLineNumber(File file) {
        if (file.exists()) {
            try {
                FileReader fileReader = new FileReader(file);
                LineNumberReader lineNumberReader = new LineNumberReader(fileReader);
                lineNumberReader.skip(Long.MAX_VALUE);
                long lines = lineNumberReader.getLineNumber()+1;   //  + 1
                fileReader.close();
                lineNumberReader.close();
                return lines;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return 0;
    }


    public static void main(String[] args) {
        String pathFile = args[0].toString();  // 测试  D:\\test01\\
        //String pathFile="D:/test01/";
        controller con = new controller();

        String lastMonth=getLastMonthDay();//获取上个月时间(yyyyMMdd)
        System.out.println("last month:"+lastMonth+"\n");


        //每个月1号生成月表文件 ,需要判断!
        if (lastMonth.lastIndexOf("0")==6&&lastMonth.lastIndexOf("1")==7) {
            con.testMonth(pathFile);
            System.out.println("\n month file product !!\n");
        }else{
            System.out.println("\nno month file product !\n");
        }
        con.testSDK(pathFile);
    }
}

二. 脚本

upload.sh

#!/bin/bash
# SFTP-20220414-v1.1
# time
source ~/.bash_profile 
EXEDATE=`date -d "-1 day"  +"%Y%m%d"`
#EXEDATE=$1   the directory proceding the txt and CHK 

# SFTP configuartion
# username          
USER=sftpaqjsyy 
# password
PASSWORD=Sftp_Dfaq_123!
# the directory proceding the txt and CHK
SRCDIR=${EXEDATE}
# directory of SFTP
DESDIR=/incoming/EC-DATA/006/
# IP
IP=172.16.248.90
# port
PORT=3948
# cd to absolute directory 
lftp -u ${USER},${PASSWORD} sftp://${IP}:${PORT}  << SFTP
cd ${DESDIR}
lcd /home/aisware/test/
lcd ${SRCDIR}
mput *.txt
mput *.CHK
close
bye
SFTP

DATE=`date`
if [ $? == 0 ]; then
        echo -e "${EXEDATE}uplaod successfully with ${DATE}"
else
        echo -e "${EXEDATE}uplaod failed with ${DATE}"
fi
crontab -e 编辑定时任务:  
	0 1 * * *  sh /home/aisware/test/write.sh >> /home/aisware/test/s.log
	5 1 * * *  sh /home/aisware/test/upload1.sh >> /home/aisware/test/s.log

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值