L
L
ldmitriy2018-12-03 14:30:48
PHP
ldmitriy, 2018-12-03 14:30:48

php exec function?

OS: windows 10;
Apache, PHP7;
I need to run an OS function, namely run ogr2ogr to convert from geojson to postgis (PostgreSQL). Maybe I need to give apache permissions.

var_dump(exec('"C:\Program Files\GDAL\ogr2ogr.exe" -f "PostgreSQL" -a_srs "EPSG:2249" 
    PG:"dbname=postgis20 user=postgres password=1" "C:\Apache24\htdocs\temp_files\file.json" -nln ABC1 -append', $output, $return));

log
Usage: ogr2ogr [--help-general] [-skipfailures] [-append] [-update]
 [-select field_list] [-where restricted_where|@filename]
 [-progress] [-sql <sql statement>|@filename] [-dialect dialect]
 [-preserve_fid] [-fid FID] [-limit nb_features]
 [-spat xmin ymin xmax ymax] [-spat_srs srs_def] [-geomfield field]
 [-a_srs srs_def] [-t_srs srs_def] [-s_srs srs_def]
 [-f format_name] [-overwrite] 
 
 Advanced options :
 [-gt n] [-ds_transaction]
 [[-oo NAME=VALUE] ...] [[-doo NAME=VALUE] ...]
 [-clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent]
 [-clipsrcsql sql_statement] [-clipsrclayer layer]
 [-clipsrcwhere expression]
 [-clipdst [xmin ymin xmax ymax]|WKT|datasource]
 [-clipdstsql sql_statement] [-clipdstlayer layer]
 [-clipdstwhere expression]
 [-wrapdateline][-datelineoffset val]
 [[-simplify tolerance] | [-segmentize max_dist]]
 [-addfields] [-unsetFid]
 [-relaxedFieldNameMatch] [-forceNullable] [-unsetDefault]
 [-fieldTypeToString All|(type1[,type2]*)] [-unsetFieldWidth]
 [-mapFieldType srctype|All=dsttype[,srctype2=dsttype2]*]
 [-fieldmap identity | index1[,index2]*]
 [-splitlistfields] [-maxsubfields val]
 [-explodecollections] [-zfield field_name]
 [-gcp pixel line easting northing [elevation]]* [-order n | -tps]
 [-nomd] [-mo "META-TAG=VALUE"]* [-noNativeData]
 
 Note: ogr2ogr --long-usage for full help.

PS from cmd this conversion works!

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
W
winbackgo, 2018-12-03
@winbackgo

var_dump will not output anything, everything is in output and return_var but add 2>&3 or 2>&1 at the end of the command and check what's in output

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question