shell_exec 不行不行

shell_exec not if does not work

check.sh 得到回显 "error01" 希望你能帮忙 这不起作用

<?php
$c = shell_exec("check.sh 2>&1");
if($a == "error01"){exit("TEST");}
echo "Wellcome";
?>

但这确实

<?php
$c = shell_exec("check.sh 2>&1");
if(isset($c)){exit("TEST");}
echo "Wellcome";
?>
"helloworld " !="helloworld"

您返回 11 个章程,但正在检查 10 个。编辑 php 或 shell 脚本。

你可以应用trim(),但最好编辑文件变量

我通过添加 $a = substr($out, 0, -1); 然后添加 if 语句 if($a == "string"); 来修复它,因为 shellscript 出于某种原因放置了 space

感谢 nogad 向我展示它在应该是 10 个字符时返回 11 个字符