Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I save the results from a MapServer file as an image? I would like to be able to write a png file as a result of a query. My query which I can display in browser is the following:

I have tried the following (which does not seem to work):


and also

wget >> myfile.png

I have seen the shp2img function but that appears to be used just for testing mapfiles. In this case I would like to use a SQL filter with my mapfile, which I don't think I can do using shp2img.

EDIT: Included first wget attempt that I tried.

share|improve this question

Just do:


You are getting some wget log output in your image file. See the manual for other information about how wget works.

share|improve this answer
That does not work for me. I get a file of this type mapserv.cgi? If I try renaming it to test.png it is not an image (I should have included this in my question as I had also tried it). – djq Oct 30 '12 at 14:33
I just tried it using GeoServer and it works for me. – iant Oct 30 '12 at 14:35
what is in the file? – iant Oct 30 '12 at 14:38
It turns out to be an error message mapserv(): Web application error. Traditional BROWSE mode requires a TEMPLATE in the WEB section, but none was provided. However, I can view it in my browser when I paste the same command in. – djq Oct 30 '12 at 14:41
so there's something wrong with your mapserver set up – iant Oct 30 '12 at 14:42
up vote 1 down vote accepted

I also asked this question on the MapServer mailing list, and Jukka Rahkonen suggested the following approach which fixed my problem:

Perhaps wget thinks that certain characters are cutting the URL string. Try wget "" -O output.png

We have used wget a lot for downloading data from WCS so I guarantee you will make it work by reading documents and trying just like we did.

share|improve this answer
The problem is that the shell interprets the & as the fork to background command, so wget sends only part of the url to the server. – unicoletti Oct 31 '12 at 15:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.