#!/bin/bash ## 验证参数大于2个参数 #if [ $# -lt 2 ]; then # echo "USAGE: $0 需要且只能携带两个日期参数,如20220101 20220102" # exit 1 #fi #if [ $# -eq 2 ]; #then # filename="814153986171547648_5G终端及5G用户数据含5G终端开关状态_hprovince_DB服务_${1}_1_12788_${2}1220.dat.gz" #elif [ $# -eq 1 ]; #then # filename="752951054268059649_intf_list_volte_users_day_${1}_0_127.dat" #else # echo "输入1个时间参数如20220101表示scp volte文件,输入2个时间参数如20220101 20220102表示scp 5G文件" # exit #fi filename=$1 localPath=$2 # scp需要密码 password=Richr00t!fast expect -c " set timeout 600 spawn scp do@133.96.92.136:/data/esbdata/WY/${filename} ${localPath} expect { \"password:\" { send \"${password}\n\"; exp_continue} timeout {send \"echo timeout\n\"; exit 2} } "