【发布时间】:2012-03-28 10:53:39
【问题描述】:
我有一个 shell 脚本,如果我在终端 (MAC OSX) 中运行它可以完美运行
#!/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 的安全模式已关闭。
【问题讨论】:
-
将 babel 的路径添加到脚本中。
-
哪个 shell 和用户是
shell_exec与您的 PHP 配置一起使用?当您在终端中运行它时,您使用的是哪个 shell 和用户?两种配置有区别吗?如果是,在哪些方面?