获取远程文件和打包

#!/bin/bash
clear
systemDate=$(date +"%Y%m%d")
systemDate2=$(date -d "1 days ago"+"%Y%m%d")
promgoodsCfg="promgoods_cfg_${systemDate}.csv"


echo "Connected to 192.168.2.1"
lftp -u name,password sftp://192.168.2.1 <<EOF
cd /home/bossftp/mall/bossinfo/promgoods_cfg
lcd /home/mecp2/files/
get $promgoodsCfg
echo "get files successful"
bye
EOF
cd /home/mecp2/files/
echo "Disconnected from 192.168.2.1"

echo "Packaged and compression the files"
tarFile="${systemDate}.prm.tar.gz"
tar -czf $tarFile *.csv
echo "Remove the csv files"
rm *.csv

你可能感兴趣的:(lftp shell)