无法从php调用远程bash脚本

无法从php调用远程bash脚本,php,bash,Php,Bash,我正在尝试使用该机器的专用IP地址执行远程bash脚本。它在同一个VLAN中。但是,我得到的结果是null。这是调用远程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 fro

我正在尝试使用该机器的专用IP地址执行远程bash脚本。它在同一个VLAN中。但是,我得到的结果是null。这是调用远程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 */

?>
输出:

{“结果”:null}

尝试使用:

exec('./path/to/bash', $result);

如果这是在另一台服务器上,我高度怀疑您是否能够执行它。您必须设置777权限(可能是安全风险,具体取决于脚本。此外,如果它在另一台服务器上,为什么不将其放在运行脚本的同一台服务器上?

我建议查看为此设计的库。phpseclib()我想到了。我有一点使用该库生成密钥的经验,但它允许您使用任何常用协议创建简单的SSH连接,并通过SSH连接运行命令


查看文档。

shellshockDo您是否意识到,如果有可能,那么没有任何东西会阻止您在google的服务器上调用bash脚本?是否有其他方法可以更安全地调用bash脚本?例如,从php触发cron作业,而php又有命令执行该shell脚本?或者从具有运行bash脚本命令的php执行java类文件?
exec('./path/to/bash', $result);