有时候用scp复制文件到远程服务器时候会遇到远程的目录是否存在的问题
bash1
ssh $SERVER_IP "[ -d $FOLDER ]" >/dev/null 2>&1
if [ $? -ne 0 ]
then
#脚本不正常退出
exit 1
fi
# >/dev/null 2>&1将标准输出和错误输出定向到null,不输出
bash2
#!/bin/bash
ssh_host=$1
filePath=$2
if ssh $ssh_host test -e $filePath;
then echo $filePathexists
else echo $filePathdoes not exist
fi
测试 ./test.sh 192.168.222.22 /temp