我的脚本设计如下 -
服务器列表放在-servers.txt。
servera01
servera02
servera03
serverb01
serverb02
serverb03
我的shell脚本是-status_check1.sh
#!/bin/bash
for i in `cat servers.txt`; do
ssh -q sv-p-jb@$i ls -l /apps/jboss/welcome-content/keepAlive.html > /dev/null
#server="$i"
if [ $? == 0 ]; then
echo -e "Server $i is in VIP | \n"
else
echo -e "Server $i is not in VIP | \n"
fi
done
我的php脚本是-test.php
<?php
exec('./status_check1.sh', $output);
#echo implode("\n", $output);
$myarray = explode('|', implode($output));
$arr_length = count($myarray);
for($i=0;$i<$arr_length;$i++)
{
echo $myarray["$i"];
echo "<br />";
echo "\r\n";
}
?>
我将php命令行(php test.php)输出为 -
servera01 is in VIP |
servera02 is in VIP |
servera03 is in VIP |
serverb01 is in VIP |
serverb02 is in VIP |
serverb03 is in VIP |
但是当我在浏览器上访问它时,低于输出。
servera01 is not in VIP
servera02 is not in VIP
servera03 is not in VIP
serverb01 is in VIP
serverb02 is in VIP
serverb03 is in VIP
你能否告诉我为什么这种不同的输出会出现在浏览器中。 我无法理解,相同的shell脚本如何在浏览器中返回'not'。
感谢。