[DUG] Shell Execute
John Bird
johnkbird at paradise.net.nz
Mon Feb 13 11:37:22 NZDT 2012
I recall there are undocumented limits on the length of line that can be executed as well from cmd and batch files, as well features such as redirect ( > and >> and | ). These may or may not work at cmd prompt level and may not work the same from a batch file, and similar limitations likely apply to Shellexecute. I was wondering if the length of your command might be hitting such a limit.
The advantage of a batch file is you can test it from a cmd prompt, if it works there then if should work from shellexecute.
I would also be inclined to put the SQL into a separate file if there was an option to do that just for tidiness, or at least put the SQL and the encoding options into separate strings, so that each can be made standard.
John Bird
From: Conor Boyd
Sent: Monday, February 13, 2012 10:31 AM
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Shell Execute
You can only ShellExecute one command at a time. You’ll have to have two separate calls to ShellExecute for your two invocations of ogr2ogr.
Only other way I can think might work would be to write a temporary batch file with both ogr2ogr invocations in it, and ShellExecute that, but I think two separate calls to ShellExecute would be clearer.
Cheers,
Conor
From: delphi-bounces at listserver.123.net.nz [mailto:delphi-bounces at listserver.123.net.nz] On Behalf Of Bob Pawley
Sent: Monday, 13 February 2012 10:20 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Shell Execute
Thanks, I missed that. However I still get only the second table blocks. The first table entities is missed.
Bob
From: Conor Boyd
Sent: Sunday, February 12, 2012 12:01 PM
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Shell Execute
Unless I’m reading it wrong, you’re missing a backslash in the path that you’re constructing to the ogr2ogr binary.
ProgramName :=
'"'+s+'\Quantum GIS Wroclaw\bin'+
'ogr2ogr"
I think there should be a slash after the “bin”?
From: delphi-bounces at listserver.123.net.nz [mailto:delphi-bounces at listserver.123.net.nz] On Behalf Of Bob Pawley
Sent: Monday, 13 February 2012 6:54 a.m.
To: DUG
Subject: [DUG] Shell Execute
Hi
I’m having a further problem with shell execute. There seems to be a dearth of information on the web other than a simple “open” procedure.
The following two part code performs well when I copy and paste it into command prompt.
However when I use it in shell execute there is a problem getting both parts to run together.
In shell execute each part of the code does its thing when the other part is commented out.
I have tried joining the two parts with the ogr2ogr command &&, and as it appears below. I have also removed the second path to ogr2ogr with no joy.
I either get “unable to run” or the second part of the code is recognized with the first part being ignored.
The following is my command prompt code – which works as shown
set PGCLIENTENCODING=LATIN1&&set DXF_ENCODING=LATIN1&&set DXF_INLINE_BLOCKS=FALSE&&set DXF_MERGE_BLOCK_GEOMETRIES=FALSE&&ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=*** password=*****" Water2000.dxf -lco DIM=2 -nlt GEOMETRY -sql "select layer, linetype, subclasses, ogr_style, blockname, blockangle, blockscale, text from entities" -append -update -skipfailures
set PGCLIENTENCODING=LATIN1&&set DXF_ENCODING=LATIN1&&set DXF_INLINE_BLOCKS=FALSE&&set DXF_MERGE_BLOCK_GEOMETRIES=FALSE&&ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=*** password=****" Water2000.dxf -lco DIM=2 -nlt GEOMETRY -append -update -skipfailures -sql "select layer, linetype, subclasses, ogr_style, blockname, text from blocks"
Here is the shell execute code which is giving me a challenge -
ProgramName :=
'"'+s+'\Quantum GIS Wroclaw\bin'+
'ogr2ogr" "-f" '+
'"PostgreSQL";'+
' PG:"host='+DBHost+' user=postgres dbname='+DBName+' password='+Pass+'" "'+ DXFfile +'" '+
' --config DXF_INLINE_BLOCKS FALSE --config DXF_MERGE_BLOCK_GEOMETRIES FALSE --config DXF_ENCODING=UTF8 '+
' -lco DIM=2 -nlt GEOMETRY -overwrite -skipfailures'+
' -sql "select layer, linetype, subclasses, ogr_style, blockname, blockangle, blockscale, text from entities"'+
'"'+s+'\Quantum GIS Wroclaw\bin'+
'ogr2ogr""-f"'+
' "PostgreSQL";'+
'PG:"host='+DBHost+' user=postgres dbname='+DBName+' password='+Pass+'" "'+ DXFfile +'" '+
' --config DXF_INLINE_BLOCKS FALSE --config DXF_MERGE_BLOCK_GEOMETRIES FALSE --config DXF_ENCODING=UTF8 '+
' -lco DIM=2 -nlt GEOMETRY -overwrite -skipfailures'+
' -sql "select layer, linetype, subclasses, ogr_style, blockname, text from blocks"';
Thanks in advance for any suggestions.
Bob
--------------------------------------------------------------------------------
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at listserver.123.net.nz with Subject: unsubscribe
--------------------------------------------------------------------------------
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at listserver.123.net.nz with Subject: unsubscribe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20120213/6dd20942/attachment.html
More information about the Delphi
mailing list