OpenWrt Forum Archive

Topic: [HELP] No one CGI script work in uhttpd

The content of this topic has been archived on 3 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

i'm trying the simplest from

http://foxlx.acmesystems.it/?id=165

http://192.168.1.1/cgi-bin/cgi.sh

#!/bin/sh
echo "Content-type: text/html\n"

# our html code
echo "<html>"
echo "<head><title>My FOX page</title></head>"
echo "<body>"
echo "<h1>Welcome to my FOX Board web page</h1>"
echo "Hello World !"
echo "</body>"
echo "</html>"

http://foxlx.acmesystems.it/foxlx/00165/screenshot1.jpg

when i placed to /www it's come to downloaded file... http://192.168.1.1/cgi.sh

but when i placed to /www/cgi-bin it's show

http://192.168.1.1/cgi-bin/cgi.sh

Content-type: text/html

<html>
<head><title>My FOX page</title></head>
<body>
<h1>Welcome to my FOX Board web page</h1>
Hello World !
</body>
</html>

what must I do to make it's work like first link above...??

(Last edited by bulongx on 16 Jul 2011, 12:46)

try this small modification

#!/bin/sh
echo    "Content-Type: text/html"
echo    "Expires: 0"
echo
# our html code
...

Change

echo "Content-type: text/html\n"

to

echo -en "Content-type: text/html\r\n\r\n"

Jow,
I was having a problem with uhttpd eating the <head>...</head> part of the html doc.  I had my cgi script put "\n\n" after the http header and it seemed to be working (on a previous html doc) until I started using a new html doc.  Switching the "\n\n" to "\r\n\r\n" completely fixed the problem ... thanks, I spent way too long trying to figure this out!

(Last edited by isaacws on 29 Jan 2012, 00:18)

The discussion might have continued from here.