Posted: Sat Dec 29, 2007 1:54 Post subject: custom cgi script broken since v24-RC3 ?
Hello!
I want to watch my system.log with the web-browser so I put a file called log.sh into /tmp/www/user/ and point my browser at http://my.routers.ip/user/log.sh - with V23 and v24-RC2 I got my system.log in my browser. I do not know exactly since which v24-build this stopped working, but at least since v24-RC4 it does not work any more.
If I tried to open the page in my browser it tells me something about "the server disconnected unexpectedly ..."
If i login via ssh and run the script by hand it works. For example:
cd /tmp/www/user
./log.sh > test.html
Now point my browser to http://my.routers.ip/user/test.html and it works (obviously now it is static content, but the output of log.sh must be right or test.html should not be displayed either)
Did the handling of custom cgi scripts changed or should i file a bug?
Were you ever able to resolve this. I too would like to add some custom cgi scripts? Do you think it is a mime type issue? Do the scripts need to be in a cgi-bin folder?
Were you ever able to resolve this. I too would like to add some custom cgi scripts? Do you think it is a mime type issue? Do the scripts need to be in a cgi-bin folder?
Right! I just found out that the scripts work without problems when they are put into /tmp/www/cgi-bin (or /jffs/www/cgi-bin) Found it at the wiki in a sidenote :-(
Right! I just found out that the scripts work without problems when they are put into /tmp/www/cgi-bin (or /jffs/www/cgi-bin) Found it at the wiki in a sidenote :-(
Is this change documented anywhere?
Bye,
eweri
Well, maybe I am stupid but since the update to V24sp1 the above does not work anymore
Well, maybe I am stupid but since the update to V24sp1 the above does not work anymore
Oh no - i am stupid - now it works - I do not know what I have done wrong before but I just set things up again with the scripts in /tmp/www/cgi-bin/ and everything works fine again.
what exactly did you do? what's the firmware? does it need to be in cgi-bin folder? Can it have other extension, than .cgi? I can't make my script run!
echo "Unix-Time here on this device is ${NOW}. Nothing usefull...<br>"
echo "Just a test..."
save this as
/tmp/www/cgi-bin/custom.sh
and make it executable:
chmod +x /tmp/www/cgi-bin/custom.sh
and point your browser to it:
http://ROUTER.IP.HERE/user/cgi-bin/custom.sh
and you should see the generated output...
This is tested with
DD-WRT v24-sp2 (10/22/08) mega - build 10564M NEWD Eko _________________ DD-WRT F.A.Q. Webcam Kiel
thank you for your reply. I don't know what happened exactly, may be the syntax of my test.cgi file was incorrect. but now it works. two questions:
1. can I pass parameters in URL like: /cgi-bin/test.cgi?param=1
I tried running the same script with parameters set and I got an error.
2. can I execute the script outside /cgi-bin/ folder?
3. can I rename my sh. script into .php file? How do I add the new content-type for it? I don't need a php interpreter.
well, still, if I can't pass parameters to script - the later two questions are irrelevant.
Joined: 18 Jun 2006 Posts: 1110 Location: Kiel (54.4247,10.1721)
Posted: Thu Oct 23, 2008 16:17 Post subject:
redsky wrote:
1. can I pass parameters in URL like: /cgi-bin/test.cgi?param=1
i am afraid no get is working. i looked in the source to see how fetchif does this, but fetchif is hardcoded in the http-daemon...
did not try post-request on custom script though...
look at httpd/modules/broadcom.c and check out do_apply_cgi...
redsky wrote:
2. can I execute the script outside /cgi-bin/ folder?
If you call them inside a script that is in the /cgi-bin/ folder you can.
redsky wrote:
3. can I rename my sh. script into .php file? How do I add the new content-type for it? I don't need a php interpreter.
well, still, if I can't pass parameters to script - the later two questions are irrelevant.
wouldn't php be a little too overbloated? what do you want to do? _________________ DD-WRT F.A.Q. Webcam Kiel
okay. I have got a phone with CID function which makes a hardcoded request to http://klicktel.det/gigasetpb/1.0/search.php and passes the CID number in the URL string.
Using /etc/hosts I can point the phone to my router instead of klicktel.de.
Now I want to put a sh script in the corresponding folder, called srcipt.php, which should parse the URL and re-request it to my own server in the internet, get a response from it and resend it back to the phone.
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=220552#220552
these are the results of my experiments. That was me who just tried post request and it worked fine. Thank you for the hint and the link to the source code.
As far as I got I won't achieve the result with this firmware.
Joined: 18 Jun 2006 Posts: 1110 Location: Kiel (54.4247,10.1721)
Posted: Thu Oct 23, 2008 17:36 Post subject:
if it is "your server", do you have access to the httpd-config? (apache would be cool)
so you could modify /etc/hosts to resolv the domain to the ip of your server, setup a virtual host that will listen to that domain name and does the stuff for you...
That's how i would handle it :)
2nd way would be to set the normal webif to a port !=80 and install a small other httpd that can handle get-queries...
add a index-page that sends header location to the new ip and you can still type in the ip of your router to manage but the get-requests would get handled...
or start a feature request... query strings in custom script could be handy for some more people
can't be that much to do... _________________ DD-WRT F.A.Q. Webcam Kiel
If it were really mine - there would be no problem at all. It's a virtual hosting provider that runs the server, so I can't set it up as a default site.
As for the second option - I am not sure that my router has enough space for installing other httpd. May be you could give me a hint where to look for some sort of tutorials?
How do I start a feature request? Besides, it may affect the router's security, so probably the developers won't do anything like that.
I haven't read these posts in detail but I'm sure my reverse-proxy solution can be of help here....
The reverse proxy can optionally rewrite the http headers.
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
Does your script still work frater? I tried a quick test and it seems to have been broken by the security fix. _________________ Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)