我正在尝试使用该机器的私有IP地址执行远程bash脚本。它在同一个VLAN中。但是,我得到null的结果是调用远程bash脚本的正确方法?无法通过php调用远程bash脚本
<?php
header('Content-Type: application/json');
$result =shell_exec('sh http://10.xxx.77.xxx/script/helloworld.sh ');
/* making json string with the result from shell script */
echo json_encode(array("result"=>$result));
/* and we are done and exit */
?>
helloworld.sh
#!/bin/bash
echo "Hello World"
输出:
{ “结果”:空}
咳嗽弹震 – 2014-09-29 02:03:29
你是否意识到如果可能的话,什么都不会阻止你在谷歌的服务器上调用bash脚本? – zerkms 2014-09-29 02:05:08
有没有其他方法以更安全的方式调用bash脚本?例如,从PHP触发cron作业,而后者又有命令执行该shell脚本? – user3846091 2014-09-29 02:24:16