Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从php运行shell脚本_Php_Macos_Shell_Babeljs - Fatal编程技术网

从php运行shell脚本

从php运行shell脚本,php,macos,shell,babeljs,Php,Macos,Shell,Babeljs,我有一个shell脚本,如果我在终端(MacOSX)上运行它,它将非常有效 我在一个名为a.sh的文件中有这个 我想使用以下方法从PHP运行此操作: $output=shell_exec(“bash a.sh 2>&1”) 这不起作用,返回: Cannot write to outputfile.inchi 0 molecules converted 1 errors 对于所有文件 我已经给了两个文件chmod777 我非常确定PHP的安全模式已经关闭 试着用巴别塔的绝对名称来称呼它。

我有一个shell脚本,如果我在终端(MacOSX)上运行它,它将非常有效

我在一个名为a.sh的文件中有这个

我想使用以下方法从PHP运行此操作:

$output=shell_exec(“bash a.sh 2>&1”)

这不起作用,返回:

  Cannot write to outputfile.inchi
0 molecules converted
1 errors 
对于所有文件

  • 我已经给了两个文件chmod777

  • 我非常确定PHP的安全模式已经关闭


试着用巴别塔的绝对名称来称呼它。使用
which babel
来确定这一点,并在脚本中用它替换“babel”。

对于运行PHP的用户来说,
babel
命令可能不在
PATH
环境变量中,因此通过PHP执行脚本。最简单的解决方案是编辑shell脚本,通过其完整路径引用babel。

将babel的路径添加到脚本中。哪个shell和用户与PHP配置一起使用?在终端中运行shell时使用的是哪个shell和用户?两种配置是否不同?如果是的,在哪几点上?谢谢,我现在似乎有进展了,我得到了一个无法写入a的错误我猜这与权限有关汉克我现在似乎有进展了,我得到了一个无法写入a的错误我猜这与权限有关谢谢你帮了我这么多
  Cannot write to outputfile.inchi
0 molecules converted
1 errors