Jump to content

Run C Program from PHP


jh_dempsey

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.