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
It is OK when I execute 'echo "830404.55 810145.46" | cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f'
with command line in Linux system.
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.
It works if I use the full path of cs2cs:
$r = system('echo "830404.55 810145.46" | /usr/bin/cs2cs +init=epsg:2326 +to +init=epsg:4326 -f %.10f', $result);