Linux shell脚本实现scp推送文件到远程

Linux shell脚本实现scp推送文件到远程
# vim myPush.sh
#!/bin/sh
BASEDIR="`dirname $0`"
ARG_CNT=$#

if [ $ARG_CNT -lt 3 ]; then
 echo "please use: $0  dst_ip  sshUser  fullPath"
 echo "eg: $0  1.1.1.1  user  /app/"
 exit 
fi
DST_IP=$1;
DST_USER=$2;

if [[ "$3" =~ .*[^/]$ ]]; then
 DST_ROOT=$3/;
else
 DST_ROOT=$3;
fi

cd "$BASEDIR"
DIR="`pwd`"
cd - > /dev/null

# sync for 3 files: 
# ./lib/engine.jar
# ./lib/engExt.jar
# ./lib2/core.jar

PATH01="lib/"
FILES01="eng*.jar"

PATH02="lib2/"
FILES02="core.jar"

# scp 
scp -r $PATH01$FILES01   $DST_USER@$DST_IP:$DST_ROOT$PATH01
scp -r $PATH02$FILES02   $DST_USER@$DST_IP:$DST_ROOT$PATH02

echo " ========================================= "
echo " all files pushed! please check the dst files! >> "

ls -l $PATH01$FILES01
ls -l $PATH02$FILES02

你可能感兴趣的:(Linux)