CGI shell script curl reponse problem

Hi,

I am running a bash shell script for some simple web server CGI, the script runs as expected from the browser except the following:

curl --silent --max-time 10 --output /dev/null --write-out %{http_code} http://server:port/filename

This line outputs 404 when i execute the script from the shell on the server, but from the browser it returns 000.

Any ideas would be welcome, thanks.