jh_dempsey Posted February 19, 2008 Share Posted February 19, 2008 Hi All I have downloaded a program called shp2text (http://www.obviously.com/gis/shp2text/) The program takes an ESRI shape file and produces an XML document. The program is written in C, and to run the program, you need to call it from the command line with parameters. An example call is like such: shp2text --gpx bike-cape_islands-geo.shp 6 0 > output.gpx shp2text is the actual exe file, --gpx sets the output format (gpx is written in xml), the next bit is the shape file (bike-cape_islands-geo.shp) and the two numbers are some options. "output.gpx" is the name of the file it will create when finished. I would be really nice if i could run this script from PHP. My ultimate aim would be to make a script that uploads the shape file to the server, runs the shp2text file on it, and then does something with the gpx file the program has just created. I have no idea and cant seem to find anything on how to go about this. I have seem functions such as exec(), system() etc.. but i dont seem to have much luck running them (i get no php error messages from them but it hasnt created the file) I need a few pointers in how to get started with this (if its possible) Does the C program need to be in a specific folder for PHP to be able to call it? How do i pass the parameters into the program? What is the best function to use to call the program? exec()? system()? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/91873-run-c-program-from-php/ Share on other sites More sharing options...
Daniel0 Posted February 19, 2008 Share Posted February 19, 2008 Just use exec() and the other functions like it (check their manual pages for the differences). E.g. exec('shp2text --gpx bike-cape_islands-geo.shp 6 0 > output.gpx'); Quote Link to comment https://forums.phpfreaks.com/topic/91873-run-c-program-from-php/#findComment-470490 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.