简体   繁体   English

PHP中的执行命令返回错误代码127

[英]Execute command in PHP returns error code 127

I am trying to execute cs2cs command for converting data format. 我正在尝试执行cs2cs命令以转换数据格式。 But it always returns error code 127 但它总是返回错误代码127

Here is the code snippet: 这是代码片段:

$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. It is OK when I execute 'echo "830404.55 810145.46" | cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f' 我执行'echo "830404.55 810145.46" | cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f' OK 'echo "830404.55 810145.46" | cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f' with command line in Linux system. 在Linux系统中,使用命令行将'echo "830404.55 810145.46" | cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f'

  2. It is OK when I execute '/var/www/html/et/test.sh' with command line in Linux system. 在Linux系统中使用命令行执行'/var/www/html/et/test.sh'可以。

Any idea of why it happens? 知道为什么会发生吗? I am not sure it is problem with PHP or cs2cs . 我不确定PHPcs2cs是否有问题。 I think it may caused by cs2cs cannot be executed by apache user account. 我认为可能是由cs2cs引起的,无法由apache用户帐户执行。 If it is the case, how to solve it? 如果是这样,如何解决? Thanks. 谢谢。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM