#!/bin/bash
initial_value=/home/VER/PlatShelfMonitor
commander="sed -i 's/"
result=0
change="/>>\\\/dev\\\/null/g'"
function modifyWrong()
{ echo "execute PlatShelfMonitor in wrong file"
echo "------------------------------"
echo "kill the old pid of PlatShelfMonitor"
id=`ps -ef | grep PlatShelfMonitor|grep -v "grep"| awk '{print $2}'`
echo $id
kill -9 $id
echo "run new PlatShelfMonitor"
/home/VER/PlatShelfMonitor >>/dev/null &
echo "run successs"
echo "-----------------------------"
result=0
echo "Result:"$result
exit 0
}
function isRight(){
echo "noting need change"
result=0
echo "Result:"$result
exit 0
}
export -f modifyWrong
export -f isRight
grep ${initial_value} /usr/sbin/zxuss|awk -F ' ' 'BEGIN {sp="k";print "begin"}
{if($1=="/home/VER/PlatShelfMonitor")
{if($2!=">>/dev/null")
{
sp=$2;
gsub(/\//,"\\/",sp);
command="'"$commander"'"sp"'"$change"'"" `grep PlatShelfMonitor -rl /usr/sbin/zxuss`";
print command;
findWrong="modifyWrong";
system(findWrong);
system(command)
}
else{
right="isRight";
system(right)
}
}
}
END {print "end"}'
echo $result