OpenWrt Forum Archive

Topic: having problem to run custom shell scripts in /www/cgi-bin/

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

Hi,
first of all I need to mention that this is my first experience with OpenWRT and I did my best to find a solution myself but no luck.

I took whiterussian rc5 and added one file blue.html to /www/cgi-bin . This file shows a splash screen and in 0 sec redirects to /www/cgi-bin/blue/test_connection.sh (second added file, readable and executable by all).

I am able to load http://192.168.1.1/blue.html , it shows up perfectly then it redirects to second file. At this stage I have a problem as browser reports - "404 Not Found. The requested URL was not found on this server."

I tried to check for possible errors in readlog but was unable to locate anything related.

I just do not know why it happens and which tools to use to track down the origin of this issue.

Need to mention that if I go to OpenWRT command shell (by ssh) and download test_connection.sh from outer server it works.

Your kind suggestions are quite appreciated.

otlabs wrote:

...added one file blue.html to /www/cgi-bin . This file shows a splash screen and in 0 sec redirects to /www/cgi-bin/blue/test_connection.sh (second added file, readable and executable by all).

I am able to load http://192.168.1.1/blue.html...

The blue.html file is in /www (the httpd's root) according to the url and you need to redirect the browser relative to /www => cgi-bin/blue/test_connection.sh.

Just check the webif or webif2 sources. Maybe you could contribute to the X-Wrt project. big_smile

kebul wrote:

The blue.html file is in /www (the httpd's root) according to the url and you need to redirect the browser relative to /www => cgi-bin/blue/test_connection.sh.

Just check the webif or webif2 sources. Maybe you could contribute to the X-Wrt project. big_smile

kebul, thanks for your input. probably I was not quite clear on what I do and what I get. I took default OpenWRT firmware and added 2 files:
/www/blue.html
/www/cgi-bin/blue/test_connection.sh

blue.html has meta refresh which leads to "/cgi-bin/blue/test_connection.sh".

If I access "http://192.168.1.1/blue.html" I do get my splash screen, and in a few seconds browser accesses "http://192.168.1.1/cgi-bin/blue/test_connection.sh", and at this stage I am getting 404 error, e.g. file not found. File test_connection.sh is in place, has executable and readable permissions set. So I do not know why httpd server reports that this file is missing. Checking "ls -l /www/cgi-bin/blue/" I can see the file, I also can "cat" it content and it is correct.

Hope that will help to see the problem I am facing.

UPDATE1: double slash removed

(Last edited by otlabs on 16 Jan 2008, 15:59)

The only thing I can see a bit problem is the double slash (//) after the IP address. Maybe it is missinterpreted by the server and therefore failling.
I had no problem to do such redirect (without double slashes) on my router's web page...

The httpd must be able to execute the file and must be able to find out what interpreter to use in case of the script.
The frequent common error is the missing interpreter line

#!/<path>/<interpreter>

in the first line.

hi,
i would like to make you know that I have solved (question to verify all files) this issue - I had some carriage returns in shell script (probably from DOS encoding) and they were killing haserl. removing CR made script to work.

thanks for your kind discussion and willing to help.

The discussion might have continued from here.