Discussion:
Can't Call shp2pgsql.exe From "Run" or VB Program, only works with DOS prompt opened first
Daniel Blomberg
2008-05-31 21:49:04 UTC
Permalink
Hi,

I am trying to run shp2pgsql.exe from inside a visual basic program I am
writing. Its not working so i tested the command I am sending from the
"Run" dialog box in windows and it doesn't work. The dos box pops up and
goes away too fast but here is what I caught:
Loading Image...

The command I am trying to run is:
"C:\gps_maps\postgis_sql\shp2pgsql.exe"
"C:\gps_maps\mississippi_topo\transportation\all_lines.shp" all_lines >
"C:\gps_maps\mississippi_topo\transportation\all_lines.sql"

If I run the command when the dos prompt is open it works. Ideas/help would
be much appreciated.

Thanks in advance
Dan
Paul Ramsey
2008-05-31 22:04:33 UTC
Permalink
The redirect may not work when running it from Run... or exec inside a
program. This sort of argues for a -f option to write out to file
without needing a stdout redirect.

P

On Sat, May 31, 2008 at 2:49 PM, Daniel Blomberg
Post by Daniel Blomberg
Hi,
I am trying to run shp2pgsql.exe from inside a visual basic program I am
writing. Its not working so i tested the command I am sending from the
"Run" dialog box in windows and it doesn't work. The dos box pops up and
http://www.gpsfiledepot.com/shp2pgsql.jpg
"C:\gps_maps\postgis_sql\shp2pgsql.exe"
"C:\gps_maps\mississippi_topo\transportation\all_lines.shp" all_lines >
"C:\gps_maps\mississippi_topo\transportation\all_lines.sql"
If I run the command when the dos prompt is open it works. Ideas/help would
be much appreciated.
Thanks in advance
Dan
_______________________________________________
postgis-users mailing list
http://postgis.refractions.net/mailman/listinfo/postgis-users
Paragon Corporation
2008-06-01 10:39:09 UTC
Permalink
Dan,

Could also be the VB code or run statement is being truncated. How are you
escaping out your double quotes in VB.

E.g. if you copy the files to root of C and then try it does it work?

Hope that helps,
Regina



-----Original Message-----
From: postgis-users-***@postgis.refractions.net
[mailto:postgis-users-***@postgis.refractions.net] On Behalf Of Paul
Ramsey
Sent: Saturday, May 31, 2008 6:05 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Can't Call shp2pgsql.exe From "Run" or VB
Program,only works with DOS prompt opened first

The redirect may not work when running it from Run... or exec inside a
program. This sort of argues for a -f option to write out to file without
needing a stdout redirect.

P
Post by Daniel Blomberg
Hi,
I am trying to run shp2pgsql.exe from inside a visual basic program I
am writing. Its not working so i tested the command I am sending from
the "Run" dialog box in windows and it doesn't work. The dos box pops
http://www.gpsfiledepot.com/shp2pgsql.jpg
"C:\gps_maps\postgis_sql\shp2pgsql.exe"
"C:\gps_maps\mississippi_topo\transportation\all_lines.shp" all_lines
Post by Daniel Blomberg
"C:\gps_maps\mississippi_topo\transportation\all_lines.sql"
If I run the command when the dos prompt is open it works. Ideas/help
would be much appreciated.
Thanks in advance
Dan
_______________________________________________
postgis-users mailing list
http://postgis.refractions.net/mailman/listinfo/postgis-users
Daniel Blomberg
2008-06-01 19:57:30 UTC
Permalink
Paul & Regina,

Paul: I noticed there is no -f option. Would I be able to run a
command direct to psql (with the | ) without having to open the
command prompt first?

Regina: I tried that, good idea though.

More diagnosing: I am able to run pgsql from my program without an
issue. I tried to run shp2pgsql.exe from a .bat file I wrote and it
also has the same error. Anyone else have any ideas?

Thanks
Dan

QUOTED:
------------------------------

Message: 4
Date: Sun, 1 Jun 2008 06:39:09 -0400
From: "Paragon Corporation" <***@pcorp.us>
Subject: RE: [postgis-users] Can't Call shp2pgsql.exe From "Run" or VB
Program, only works with DOS prompt opened first
To: "'PostGIS Users Discussion'"
<postgis-***@postgis.refractions.net>
Message-ID: <000501c8c3d3$b936ef00$***@l>
Content-Type: text/plain; charset="us-ascii"

Dan,

Could also be the VB code or run statement is being truncated. How are you
escaping out your double quotes in VB.

E.g. if you copy the files to root of C and then try it does it work?

Hope that helps,
Regina



-----Original Message-----
From: postgis-users-***@postgis.refractions.net
[mailto:postgis-users-***@postgis.refractions.net] On Behalf Of Paul
Ramsey
Sent: Saturday, May 31, 2008 6:05 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Can't Call shp2pgsql.exe From "Run" or VB
Program,only works with DOS prompt opened first

The redirect may not work when running it from Run... or exec inside a
program. This sort of argues for a -f option to write out to file without
needing a stdout redirect.

P

On Sat, May 31, 2008 at 2:49 PM, Daniel Blomberg <***@gpsfiledepot.com>
wrote:

Hi,

I am trying to run shp2pgsql.exe from inside a visual basic program I
am writing. Its not working so i tested the command I am sending from
the "Run" dialog box in windows and it doesn't work. The dos box pops
up and goes away too fast but here is what I caught:
http://www.gpsfiledepot.com/shp2pgsql.jpg

The command I am trying to run is:
"C:\gps_maps\postgis_sql\shp2pgsql.exe"
"C:\gps_maps\mississippi_topo\transportation\all_lines.shp" all_lines

"C:\gps_maps\mississippi_topo\transportation\all_lines.sql"

If I run the command when the dos prompt is open it works. Ideas/help
would be much appreciated.

Thanks in advance
Dan
Dan Blomberg
2008-06-01 21:50:26 UTC
Permalink
Everyone,

I actually figured out how to make this work by viewing the php code for
the DCMMS application. I needed to add the database after the table
name and now it works.

In case anyone else runs into this the command I now use is:
"C:\gps_maps\postgis_sql\shp2pgsql.exe" -d
"C:\gps_maps\mississippi_topo\transportation\all_lines.shp" all_lines
postgis > "C:\gps_maps\mississippi_topo\transportation\all_lines.sql"

Dan
Post by Daniel Blomberg
Paul & Regina,
Paul: I noticed there is no -f option. Would I be able to run a command direct to psql (with the | ) without having to open the command prompt first?
Regina: I tried that, good idea though.
More diagnosing: I am able to run pgsql from my program without an issue. I tried to run shp2pgsql.exe from a .bat file I wrote and it also has the same error. Anyone else have any ideas?
Thanks
Dan
------------------------------
Message: 4
Date: Sun, 1 Jun 2008 06:39:09 -0400
Subject: RE: [postgis-users] Can't Call shp2pgsql.exe From "Run" or VB
Program, only works with DOS prompt opened first
To: "'PostGIS Users Discussion'"
Content-Type: text/plain; charset="us-ascii"
Dan,
Could also be the VB code or run statement is being truncated. How are you
escaping out your double quotes in VB.
E.g. if you copy the files to root of C and then try it does it work?
Hope that helps,
Regina
-----Original Message-----
Ramsey
Sent: Saturday, May 31, 2008 6:05 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Can't Call shp2pgsql.exe From "Run" or VB
Program,only works with DOS prompt opened first
The redirect may not work when running it from Run... or exec inside a
program. This sort of argues for a -f option to write out to file without
needing a stdout redirect.
P
Post by Daniel Blomberg
Hi,
I am trying to run shp2pgsql.exe from inside a visual basic program I
am writing. Its not working so i tested the command I am sending from
the "Run" dialog box in windows and it doesn't work. The dos box pops
http://www.gpsfiledepot.com/shp2pgsql.jpg
"C:\gps_maps\postgis_sql\shp2pgsql.exe"
"C:\gps_maps\mississippi_topo\transportation\all_lines.shp" all_lines
Post by Daniel Blomberg
"C:\gps_maps\mississippi_topo\transportation\all_lines.sql"
If I run the command when the dos prompt is open it works. Ideas/help
would be much appreciated.
Thanks in advance
Dan
_______________________________________________
postgis-users mailing list
http://postgis.refractions.net/mailman/listinfo/postgis-users
Lê Viết Thanh
2008-06-02 14:05:22 UTC
Permalink
A quick and dirty workaround, you can generate to a batch file and recall it
in VB.
Post by Dan Blomberg
Everyone,
I actually figured out how to make this work by viewing the php code for
the DCMMS application. I needed to add the database after the table name
and now it works.
"C:\gps_maps\postgis_sql\shp2pgsql.exe" -d
"C:\gps_maps\mississippi_topo\transportation\all_lines.shp" all_lines
postgis > "C:\gps_maps\mississippi_topo\transportation\all_lines.sql"
Dan
Paul & Regina,
Paul: I noticed there is no -f option. Would I be able to run a command direct to psql (with the | ) without having to open the command prompt first?
Regina: I tried that, good idea though.
More diagnosing: I am able to run pgsql from my program without an issue. I tried to run shp2pgsql.exe from a .bat file I wrote and it also has the same error. Anyone else have any ideas?
Thanks
Dan
------------------------------
Message: 4
Date: Sun, 1 Jun 2008 06:39:09 -0400
Subject: RE: [postgis-users] Can't Call shp2pgsql.exe From "Run" or VB
Program, only works with DOS prompt opened first
To: "'PostGIS Users Discussion'"
Content-Type: text/plain; charset="us-ascii"
Dan,
Could also be the VB code or run statement is being truncated. How are you
escaping out your double quotes in VB.
E.g. if you copy the files to root of C and then try it does it work?
Hope that helps,
Regina
-----Original Message-----
Ramsey
Sent: Saturday, May 31, 2008 6:05 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Can't Call shp2pgsql.exe From "Run" or VB
Program,only works with DOS prompt opened first
The redirect may not work when running it from Run... or exec inside a
program. This sort of argues for a -f option to write out to file without
needing a stdout redirect.
P
Hi,
I am trying to run shp2pgsql.exe from inside a visual basic program I
am writing. Its not working so i tested the command I am sending from
the "Run" dialog box in windows and it doesn't work. The dos box pops
up and goes away too fast but here is what I caught:http://www.gpsfiledepot.com/shp2pgsql.jpg
"C:\gps_maps\postgis_sql\shp2pgsql.exe"
"C:\gps_maps\mississippi_topo\transportation\all_lines.shp" all_lines
"C:\gps_maps\mississippi_topo\transportation\all_lines.sql"
If I run the command when the dos prompt is open it works. Ideas/help
would be much appreciated.
Thanks in advance
Dan
_______________________________________________
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
http://postgis.refractions.net/mailman/listinfo/postgis-users
thomas gratier
2008-06-02 19:15:21 UTC
Permalink
Dan,

I can't directly help you but some people works about vbs for importing shp
via shp2pgsql.
Let's have a look on this post
http://georezo.net/forum/viewtopic.php?id=47156 (in the middle of this
french topic, you have VBS code )

Hope it helps

Thomas G
Dan Blomberg
2008-06-02 20:06:45 UTC
Permalink
Awesome, I now have it working exactly as I wanted.

Having it create a bat file and then run that also worked once I figured
out to include the database.

Thanks everyone
Dan
Post by thomas gratier
Dan,
I can't directly help you but some people works about vbs for
importing shp via shp2pgsql.
Let's have a look on this post
http://georezo.net/forum/viewtopic.php?id=47156 (in the middle of this
french topic, you have VBS code )
Hope it helps
Thomas G
------------------------------------------------------------------------
_______________________________________________
postgis-users mailing list
http://postgis.refractions.net/mailman/listinfo/postgis-users
Brundage, Robert G Mr CIV USA IMCOM
2008-06-02 21:00:31 UTC
Permalink
I am running shp2pgsql.exe from C# using a process(cmd.exe,"string
including executable name and options")


Bob Brundage
GIS Coordinator
Public Works (DPW)
Bldg 865 Bastogne Ave & 16th St
For Campbell, KY 42223
PH: 270-798-9571
FAX: 270-798-2232
-----Original Message-----
From: postgis-users-***@postgis.refractions.net
[mailto:postgis-users-***@postgis.refractions.net] On Behalf Of Dan
Blomberg
Sent: Monday, June 02, 2008 3:07 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Re: Can't Call shp2pgsql.exe From "Run" or
VBProgram, only works with DOS prompt opened first

Awesome, I now have it working exactly as I wanted.

Having it create a bat file and then run that also worked once I figured
out to include the database.

Thanks everyone
Dan

thomas gratier wrote:

Dan,

I can't directly help you but some people works about vbs for
importing shp via shp2pgsql.
Let's have a look on this post
http://georezo.net/forum/viewtopic.php?id=47156 (in the middle of this
french topic, you have VBS code )

Hope it helps

Thomas G




________________________________


_______________________________________________
postgis-users mailing list
postgis-***@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Loading...