【问题标题】:Execute command in PHP returns error code 127在 PHP 中执行命令返回错误代码 127
【发布时间】:2013-02-04 08:58:43
【问题描述】:

我正在尝试执行 cs2cs 命令来转换数据格式。但它总是返回错误代码 127

这里是sn-p的代码:

$r = system('echo "830404.55 810145.46" | cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f', $result);
//$r = system('sh /var/www/html/et/test.sh', $result); // returns error code 127
echo $r.'<br>'; // print nothing
echo $result.'<br>'; // print 127
  1. 在Linux系统中用命令行执行'echo "830404.55 810145.46" | cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f'就OK了。

  2. 用命令执行'/var/www/html/et/test.sh'就OK了 Linux系统中的行。

知道为什么会这样吗?我不确定 PHPcs2cs 是否有问题。我认为这可能是由于 cs2cs 无法由 apache 用户帐户执行。如果是这种情况,如何解决?谢谢。

【问题讨论】:

  • 看来你的apache用户没有执行命令的权限
  • 你知道如何解决它吗?

标签: php system execute


【解决方案1】:

如果我使用cs2cs的完整路径就可以了:

$r = system('echo "830404.55 810145.46" | /usr/bin/cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f', $result);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-17
    • 2018-04-03
    • 2017-10-02
    • 1970-01-01
    • 2022-12-18
    • 1970-01-01
    • 2018-03-04
    • 1970-01-01
    相关资源
    最近更新 更多