- 论坛徽章:
- 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}" #这一步执行出错
- #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
复制代码 追踪执行过程,远程执行sed那一步有问题,我也不知道错误在哪里... 请教高手
+++ 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
|
|