[英]How to exec the shell script in PHP
I'm making PHP script to move shell script. 我正在制作PHP脚本来移动Shell脚本。 when hoge < 50
. 当hoge < 50
。
Code is this. 代码是这个。 Does it OK? 可以吗
When I use that script , I click this link. 使用该脚本时,我单击此链接。
http://localhost/index.php?hoge=30 HTTP://localhost/index.php霍格= 30
<?php
if(isset($_GET['hoge'])) {
$hoge = $_GET['hoge'];
print("$hoge<br>\n");
}
if ($hoge > 50 ){
echo 'F1';
}
elseif ($hoge == 50) {
echo 'F2';
} else {
echo 'F3';
exec(' /Users/hoge/Desktop/test.sh');
}
?>
You can add a test like 您可以添加类似的测试
if (file_exists('/Users/hoge/Desktop/test.sh')) {
exec('/Users/hoge/Desktop/test.sh');
} else {
echo 'NO FILE'
}
Check also that the file /Users/hoge/Desktop/test.sh is executable 还要检查文件/Users/hoge/Desktop/test.sh是否可执行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.