- 論壇徽章:
- 0
|
- #!/bin/bash
- set -x
- LOGIN_USER=testuser1
- XML_FILE='/tmp/test.xml'
- Failed_log=/tmp/failed.log
- remote_host="${HOST}" #HOST為另一腳本變量
- ping -c 1 ${HOST} > /dev/null 2>&1
-
- if [ $? != 0 ];then
- echo "${HOST} | ERROR : can't reach server ${HOST}" | tee -a ${Failed_LOG}
- else
- ssh -q "${LOGIN_USER}"@"${remote_host}" "echo test" > /dev/null
- if [ $? != 0 ];then
- echo "${HOST} | ERROR : SSH Login failed for server ${HOST}" | tee -a ${Failed_LOG}
- else
- line=$(ssh -q -t $LOGIN_USER@"${remote_host}" "cat -n $XML_FILE | grep -F '<key>Server</key>'|awk '{print \$1}'")
- line=`echo $line | sed 's#\\r##g'`
- line=$(($line + 1))
- vp=$(ssh -q -t $LOGIN_USER@"${remote_host}" "cat -n $XML_FILE | grep -F $line | awk -F '>' '{print \$2}'|awk -F '<' '{print \$1}'")
- #SED_COMMAND="sed -i "s/$vp/$EDGE/g" $XML_FILE"
- ssh -t $LOGIN_USER@"${remote_host}" "/bin/sed -i s/${vp}/${EDGE}/g ${XML_FILE}" #這一步執(zhí)行出錯(cuò)
- #tt=$(ssh $LOGIN_USER@"${remote_host}" "find -type f -name ${XML_FILE}|xargs perl -pi -e 's|${vp}|${EDGE}|g'")
- nvp=$(ssh -q -t $LOGIN_USER@"${remote_host}" "cat -n $XML_FILE | grep -F $line | awk -F '>' '{print \$2}'|awk -F '<' '{print \$1}'")
- fi
- fi
復(fù)制代碼
追蹤執(zhí)行過程,遠(yuǎn)程執(zhí)行sed那一步有問題,我也不知道錯(cuò)誤在哪里...
+++ ssh -q -t testuser1@tcd1a 'cat -n /tmp/test.xml | grep -F 198 | awk -F '\''>'\'' '\''{print $2}'\''|awk -F '\''<'\'' '\''{print $1}'\'''
++ vp=$'test,stedgevp01\r'
/test/g /tmp/test.xml'd1a '/bin/sed -i s/test,stratisedgevp01
|
|