0

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

这是代码片段:

$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. 'echo "830404.55 810145.46" | cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f'在Linux系统中用命令行执行就可以了。

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

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

4

1 回答 1

2

如果我使用 cs2cs 的完整路径,它会起作用:

$r = system('echo "830404.55 810145.46" | /usr/bin/cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f', $result);
于 2013-02-06T09:35:48.220 回答