HG Command无法使用php

时间:2014-12-12 05:15:44

标签: php shell mercurial

我有一个基本的部署程序,我想自动化它。我使用php从Php自动化我正在调用shell脚本。如果我使用php& shell脚本HG命令不起作用。

以下是我的示例代码。

的index.php

<?php
startBuild();

function startBuild() {
    echo shell_exec('sh makeBuild.sh 2>&1');
}
?>

makeBuild.sh

#!/bin/bash
hg pull <hg-path>
hg archive -r1673 --verbose /Users/system1/Sites/Apps/001225035079/1.3

浏览器我正在运行

http://localhost/~system1/Sites/index.php

执行网页时收到错误,因为&#39; makeStandalone.sh:第7行:hg:命令未找到makeStandalone.sh:第8行:hg:命令未找到&#39;

如果我从Terminate.app运行makeBuild.sh,它可以正常工作。

请帮我解决这个问题,提前谢谢。

1 个答案:

答案 0 :(得分:1)

在这种情况下,似乎hg可执行文件的完整路径会有所帮助。将脚本更改为:

#!/bin/bash
/path/to/hg pull <hg-path>
/path/to/hg archive -r1673 --verbose /Users/system1/Sites/Apps/001225035079/1.3

/path/to/hg替换为正确的安装路径。