Can I run shell script using LUCI?

I am trying to call http://192.168.1.1/updatefirewall.sh?ip=3ba2:95bc:c00f:8d02:7b16:088e:8086:f980
but the browser is downloading the updatefirewall.sh file instead of executing it, is it possible to call the shell script using a url?

2 Likes

Luci is served by the web server uhttpd. So it will be uhttpd that could run your script.

If you just want to run a shell script, put it in /www/cgi-bin/ and flag it executable.
The url will then be:
http://192.168.1.1/cgi-bin/updatefirewall.sh?ip=3ba2:95bc:c00f:8d02:7b16:088e:8086:f980

EDIT: The query string, ie everything after the "?", is sent to the script in the variable $QUERY_STRING

Any output from your script will be shown on the browser, so you could generate suitable html in the script if you wanted to.
Here is an example:

I've had it done before with uhttpd, probably an issue with the web-server instance you're using. If you're using uhttpd post your instance parameters, I'll compare with my code.

I ll try that, I just want to run a shell script that I can call it from my raspberry pi so that it is allowed in IPv6 firewall whenever the ip address changes.

1 Like