PDA

Bekijk de volledige versie : Cgi-bin whats wrong



phobos2
21-10-2004, 01:27
Script>http://my.router:81/cgi-bin/test.cgi
#!/bin/sh
uptime

>server busybox_httpd -p 81 -h /tmp/harddisk/www
chmod +x test.cgi also done
file in www/cgi-bin/
whats wrong. Pls help...

yato
22-10-2004, 16:34
You should send some HTTP headers before page content. Nobody does it for you, as opposite to serving static pages.
try this:

#!/bin/sh
cat <<EOH
Content-type: text/plain

EOH
uptime

note blank line after HTTP header!

Styno
22-10-2004, 22:04
Check out the following Wiki page:
http://wiki.wl500g.info/index.php/PackageWebserver

And an example of an cgi-bin script:
http://wiki.wl500g.info/index.php/HttpScriptSystemInfo

yato
23-10-2004, 18:47
I will correct myself: busybox_httpd IS sending Content-type: text/plain header if you forget to send HTTP headers (I have checked it in source code). So it was not the problem you had.
Nevertheless you should send HTTP headers if you plan to return HTML, image or so. The above mentioned Wiki page was not doing that though :( .

AmoRico
23-01-2005, 05:53
I have been trying to get the cgi-bin scripts working since I got my WL-500, unfortunately, with no luck. I have been reading all the posts and made lots of search. I dont know what I might be doing wrong. But straight to the point!

First I wanted to ask for help as well, but I finally got my first script to work.

Here is where was the problem:

when I opened the script in vi editor I got this:


´╗┐#!/bin/sh^M
^M
.
.
.

No wonder it wasnt working. I fixed it in the editor saved and woohoo...
Hopefully it will help all the people that had trouble solving this problem.

Oleg
23-01-2005, 16:43
The problem is that you've added this script in windows (this adds ^M) and saved file in UTF-8 format...