Linuxshell脚本实现scp推送⽂件到远程版权声明:本⽂为博主原创⽂章,未经博主允许不得转载。 blog.csdn/sunny05296/article/details/65973159
Linux shell脚本实现scp推送⽂件到远程
# vim myPush.sh
#!/bin/sh
BASEDIR="`dirname $0`"
ARG_CNT=$#
linux shell编程求和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
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论