Opened 11 years ago

Closed 11 years ago

#4969 closed defect (duplicate)

Can't read /vsistdout/ via php's popen() on Mac OS X Mountain Lion

Reported by: dtarc Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SRS Version: unspecified
Severity: normal Keywords: vsistdout ogr2ogr
Cc:

Description

Hi,

I think the issue I am having is with my php configuration as opposed to something ogr2ogr is doing but this seems like the most likely place to get help.

We've been using ogr2ogr to do geodata conversions in a drupal project for over a year now. We have it running on various servers and it was working fine on my dev environment. Recently I rebuilt my dev environment, switching from Mac OS X Lion to Mac OS X Mountain Lion and starting from scratch, and I can no longer get valid info back when calling ogr2ogr from PHP.

I am using MAMP and PHP 5.3.14. Also using the bare bones drupal module (http://drupal.org/project/ogr2ogr). I was using GDAL 1.9.2, but when it wasn't working I downgraded to 1.8.1. I have installed it using Homebrew.

GDAL seems to be installed correctly as I can call ogr2ogr commands from the command line and I get valid data returned. When I call the same command from PHP, I don't get anything back.

Here is the command I am trying to run:

/usr/bin/ogr2ogr -f CSV /vsistdout/ "/path/to/SHAPEFILE.shp" -lco GEOMETRY=AS_WKT -t_srs EPSG:4326

If I run it from the command line, I get valid WKT results returned in CSV format.

Running from PHP, I'm executing the following code:

<code>

Build $command

...

if (($handle = popen($command, "r")) !== FALSE) {

while (($data = fgetcsv($handle)) !== FALSE) {

Process incoming data

}

}

</code>

The popen command seemed to return a valid file handle and gets evaluated as TRUE. Hoever the fgetcsv() call always returns FALSE. I have subbed in fgets() and that will also return FALSE. Again, this is an ogr2ogr command that returns data when called from the shell.

I got a tip to make sure that the php environment variable auto_detect_line_endings was set to TRUE but that did not help.

Does anyone have any suggestions? Thanks in advance.

Change History (1)

comment:1 by Even Rouault, 11 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.