I really don't think you are going about this the right way.
I don't know if you ended up using NCS or httpd, but if it's teh first you use the variables it provides in a script, if it's the second you set it up also in a script.
In Administration > Commands > Start up/Custom script.
And also use the scheduler in Administration > Management > Cron.
All this requires Bash knowledge.
On the other hand, modifying the code, which seems to be your method, might originate bugs, conflicts and makes it impossible to upgrade.
i may be going down the wrong track.
i want to see if i can use the existing httpd without any modifications to it. the routers admin pages save and restore state. httpd uses nvram to persist state. i am trying to find the code or program that does this for the state that gets posted to the admin pages.
i understand sh.
i would like to add my own web page that saves and restores one string variable. this is for some dedicated android tablets talking to a dedicated router.
there are dozens of .webconfig files in www/ that fool around with nvram and capture, so i assume that this is where that persistence gets done, but i don't know where capture is defined.
is there any docs on how the .webconfig filed get used or the capture function?
thanks
The only way to save this state is through a startup script, this script is saved in the NVRAM.
The startup script is just bash, meaning, it's a set of command line parameters for the Linux CLI. Somewhat similar to batch in Windows CLI.
So, to start an instance of httpd you would type: 'httpd <parameters>' on the console, this can be automated via a startup script that starts httpd with those parameters every time.
Let me give you an example of a startup script that I created that installs the program cURL on my router every time (this is necessary because I need cURL for other scripts and dd-wrt doesn't come with it, since this router, ASUS RT-N10+ B1, has no way to had any other persistent storage I use NVRAM for this).
Code:
if test -d /tmp/bin; then exit 0; fi
# Download and install curl
PATH2PKG="http://downloads.openwrt.org/chaos_calmer/15.05.1/ramips/rt305x/packages/base/"
sleep 30
until ping -c 1 openwrt.org &> /dev/null && ping -c 1 curl.haxx.se &> /dev/null; do sleep 30; done
mkdir /tmp/test
cd /tmp/test
until wget -qT 30 "$PATH2PKG"; do sleep 2; done
CURLP=$(cat index.html | grep curl | awk -F '"' '{print $2}' | head -n 1)
LIBCURLP=$(cat index.html | grep libcurl | awk -F '"' '{print $2}' | head -n 1)
LIBPOLARP=$(cat index.html | grep libpolarssl | awk -F '"' '{print $2}')
until wget -qT 30 "$PATH2PKG""$CURLP"; do sleep 2; done
until wget -qT 30 "$PATH2PKG""$LIBCURLP"; do sleep 2; done
until wget -qT 30 "$PATH2PKG""$LIBPOLARP"; do sleep 2; done
tar -zxf $CURLP
tar -zxf data.tar.gz
rm data.tar.gz
tar -zxf $LIBCURLP
tar -zxf data.tar.gz
rm data.tar.gz
tar -zxf $LIBPOLARP
tar -zxf data.tar.gz
mv usr/* /tmp
cd ..
rm -rf test
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/tmp/lib
export PATH=${PATH}:/tmp/bin
until curl -k -s -m 30 -o /tmp/cacert.pem https://curl.haxx.se/ca/cacert.pem; do sleep 2; done
sleep 2
exit
Do you really? Maybe you should think in 'first principle' terms, of, globally, think of what you want to achieve, you aren't looking for a solution to a problem, you think you already have a solution and you are looking for a problem.
You should start with what you can do with the stock dd-wrt, namely, using something simple as nocatsplash, because you might have more flexibility on the Android side. And in that case sending a POST or a GET might not be the solution to your problem.
I would stop trying to look at the httpd code and how it controls the webui because you can't control or tap into that without modifying the code.
As for what exact approach I would suggest, to tell you truth I haven't really given much thought about your specific case (and I won't), I just got the general idea, and I know the way you started going about this is the wrong approach. Again, I'm not proposing a solution, I'm just suggesting you take a different approach that starts from what you can easily do in DD-WRT.
The script I posted is a example of how: 1) you can create any text file from a a script, 2) the potential of the startup script, in the specific case, used to install software on the router.
Do you really? Maybe you should think in 'first principle' terms, of, globally, think of what you want to achieve, you aren't looking for a solution to a problem, you think you already have a solution and you are looking for a problem.
You should start with what you can do with the stock dd-wrt, namely, using something simple as nocatsplash, because you might have more flexibility on the Android side. And in that case sending a POST or a GET might not be the solution to your problem.
i was initially turned off by the hot spot stuff as it did all kinds of things that i do not need and i did not want to fire up another service.
also, what else would i do over http besides a get or a post?
Specimen wrote:
I would stop trying to look at the httpd code and how it controls the webui because you can't control or tap into that without modifying the code.
As for what exact approach I would suggest, to tell you truth I haven't really given much thought about your specific case (and I won't), I just got the general idea, and I know the way you started going about this is the wrong approach. Again, I'm not proposing a solution, I'm just suggesting you take a different approach that starts from what you can easily do in DD-WRT.
The script I posted is a example of how: 1) you can create any text file from a a script, 2) the potential of the startup script, in the specific case, used to install software on the router.
There other methods besides post or get, you can set a cookie strictly using HTML. And you can also use JScript, as that is all processed on the client side.
There other methods besides post or get, you can set a cookie strictly using HTML. And you can also use JScript, as that is all processed on the client side.
i have DD-WRT v24SP2- (11/05/13) std (SVN revision 22750), but there is no mention of jffs on adminstration|management. there is a line: show_layer_ext(document.setup.enable_jffs2, 'idjffs2', 0 == 1); in the page source.
i did an nvram set enable_jffs2=1, and nvram show | grep jffs says: enable_jffs2=1. i restarted the browser, bit still no jffs support in the web page.
i did an nvram commit and cycled power on the router, still no joy
The instructions are for routers that have external storage. But I already showed you before how to use the NVRAM to write files to /tmp/ using the startup command and echo.
You can research by yourself what JFFS2 is for and how relates to external storage, don't expect me to explain it.
This project seems to be too ambitious for your understanding of DD-WRT and your willingness to research for yourself.
The instructions are for routers that have external storage. But I already showed you before how to use the NVRAM to write files to /tmp/ using the startup command and echo.
You can research by yourself what JFFS2 is for and how relates to external storage, don't expect me to explain it.
This project seems to be too ambitious for your understanding of DD-WRT and your willingness to research for yourself.
i did write a startup script that created a web page in /www/user/. the browser can retrieve this file.
but i still have no idea how to access the query or the form submit data from the html file or deal with a cookie.
The instructions are for routers that have external storage. But I already showed you before how to use the NVRAM to write files to /tmp/ using the startup command and echo.
You can research by yourself what JFFS2 is for and how relates to external storage, don't expect me to explain it.
This project seems to be too ambitious for your understanding of DD-WRT and your willingness to research for yourself.
i did write a startup script that created a web page in /www/user/. the browser can retrieve this file.
but i still have no idea how to access the query or the form submit data from the html file or deal with a cookie.
thanks
You don't know enough HTML/JS to do this. This is not an HTML/JS forum.
And quite frankly I haven't seen any good reason as to why NoCatSplash is not suitable for you, you can also write the webpage clients access in NCS. And the concern about having another service running is ridiculous, how would that be different than running another instance of httpd.
You decided to pick the most difficult path and you are out of your depth.
PS
Besides you are using a +2 year old version of DD-WRT, which means you don't really know much about DD-WRT releases. DD-WRT wiki, documentation and site is outdated, releases work in a permanent beta state and can be found here ftp://ftp.dd-wrt.com/betas/2016/
The most updated information is found scattered in the forums.
You are using a poorly documented tool, for the first time. to achieve something that is non-standard and you refuse to try the standard tools it comes with.
Your best bet would be to find something similar someone had already implemented and documented.