Bash / CGI - Premature end of script headers


When trying to add a image to your CGI script you recieve the following error and the image isnt displayed.

[root@localhost cgi-bin]# cat /var/log/httpd/error_log
[Fri Jul 10 20:51:39 2009] [error] [client] Premature end of script headers: picture2.jpg, referer:
[Fri Jul 10 20:57:57 2009] [error] [client] (8)Exec format error: exec of '/var/www/cgi-bin/picture2.jpg' failed, referer:


Add to your httpd.conf or apache.conf file an alias such as,

Alias /images/legacy/ /usr/share/images/legacy/

Once added restart you httpd/apache daemon. And add your images to the directory.

unset PATH
echo "Content-type: text/html"
echo ""
echo "<html>"
echo    "<body>"
echo            "<img src="/images/legacy/picture.jpg">"
echo    "</body>"
echo "</html>"

 Your page should now display the picture.