1

如果我在终端(MAC OSX)中运行它,我有一个完美运行的 shell 脚本

#!/bin/bash
cd /Applications/XAMPP/xamppfiles/htdocs/chemedit/

babel -imol  'a.mol' -oinchi 'outputfile.inchi'
babel -imol  'a.mol' -osmi 'a.smsi'
babel a.smi -O out.svg  -xC -xe
exit

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

我想从 PHP 运行它:

$output = shell_exec("bash a.sh 2>&1");

这不起作用并返回:

  Cannot write to outputfile.inchi
0 molecules converted
1 errors 

对于所有文件

  • 我已经给了两个文件 chmod 777。

  • 我很确定 PHP 的安全模式已关闭。

4

2 回答 2

2

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

于 2012-03-12T00:28:47.003 回答
1

尝试使用其绝对名称调用 babel。用于which babel确定这一点,并在脚本中用它替换 'babel'。

于 2012-03-12T00:27:34.327 回答