dispatch_so(){
MAPPING_FILE=$1
SRC_HOME=$2
for fn in ${folder_list[*]}
do
echo "====="
while IFS='=' read -r SRC TARGET USERS PASWD TARGETDIR
do
if [ "$SRC" = "$fn" ];then
echo "scp ${SRC_HOME}/${SRC} ${USERS}@${TARGET}:${TARGETDIR}"
scp ${SRC_HOME}/${SRC} ${USERS}@${TARGET}:${TARGETDIR}
if [ $? = 0 ];then RES="success";else RES="failed";fi
fi
#echo "$MAPPING_FILE"
done < ${MAPPING_FILE}
if [ "$RES" = "success" ]
then
echo "succ===$fn"
# echo "rm -rf ${PACK_HOME}/$fn"
# rm -rf ${PACK_HOME}/$fn;
fi
done
}
将上述代码echo出的语句直接执行。可以成功将文件传输过去,且不会出现文件名为?的情况。
echo出来的命令为:scp /home/contin/packs/test.so cina@10.20.27.100:/home/cina/ssr/
传输结果为:-rw-r--r-- 1 cina testd 240770 4月 11 15:37 ?