Popular
Latest Articles
- How to Secure your Cisco Router
- Creating CLI Views on a Cisco Router
- Configuring TACACS+ on a Cisco Router
- How to enable SDM on your router
- Build a Samba Server on Redhat / CentOS
- How to set the Time / Date and Timezone in CentOS
- How to install SSH on Solaris 10 x86
- ESX4 - How do I turn on/off a Virtual Machine from the command line ?
Bash / CGI - Premature end of script headers
Friday, 10 July 2009 21:21
Issue
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 10.2.2.5] Premature end of script headers: picture2.jpg, referer: http://10.2.2.1/cgi-bin/picture.cgi
[Fri Jul 10 20:57:57 2009] [error] [client 10.2.2.5] (8)Exec format error: exec of '/var/www/cgi-bin/picture2.jpg' failed, referer: http://10.2.2.1/cgi-bin/picture.sh
Solution
Add to your httpd.conf or apache.conf file an alias such as,
Alias /images/ /usr/share/images/
Once added restart you httpd/apache daemon. And add your images to the directory.
#!/bin/sh
unset PATH
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<body>"
echo "<img src="/images/picture.jpg">"
echo "</body>"
echo "</html>"
Your page should now display the picture.