简体   繁体   中英

Execute command in PHP returns error code 127

I am trying to execute cs2cs command for converting data format. But it always returns error code 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' with command line in Linux system.

  2. It is OK when I execute '/var/www/html/et/test.sh' with command line in Linux system.

Any idea of why it happens? I am not sure it is problem with PHP or cs2cs . I think it may caused by cs2cs cannot be executed by apache user account. 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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