-1
我有一个url数组。我有一个脚本来打开它们,如果它们没有任何错误打开,显示状态为运行,否则不运行。现在我想用这种状态替换HTML中的url({ABC_Service_Status})的相应状态。我在哪里把我的sed语句,以及如何从URL中切只是ABCService
Shell替换文件中的字符串
urlArray=('http://server:port/ABCservice/services/ABCservice?wsdl' 'http://server:port/DEFservice/services/DEFservice?wsdl')
for url in "${urlArray[@]}"
do
result=`curl $url | head -1`
if (echo $result | grep '<?xml' >/dev/null 2>&1); then
echo Running
else
echo Not Running
fi
done
电流输出:
Running
Not Running
我有以下内容的HTML文件(version.html)
<tr><td>ABCService</td><td>12.11.0</td><td>{ABCService_Status}</td>/tr>
<tr><td>DEFService</td><td>12.11.0</td><td>{DEFService_Status}</td>/tr>
希望的输出替换后:
<tr><td>ABCService</td><td>12.11.0</td><td>Running</td>/tr>
<tr><td>DEFService</td><td>12.11.0</td><td>Not Running</td>/tr>