Topic: Having trouble with GETPARAM

Can't seem to read the parameters in javascript.  If I enter the commands via URL i get back the correct quasi XML.

Here is what I'm doing

        xmlhttpa=new XMLHttpRequest();"GET","http://localhost/bridge?cmd=getparam&value=boxid",false);
xmldoc seems to be null.

Re: Having trouble with GETPARAM

How did you set your 'boxid' variable? Did you manually put it in /psp/parameters.ini?
This won't work for your current firmware because /psp/parameters.ini is loaded into memory only once everytime the browser starts.
If you have use SetParam & then GetParam immediately after that, it will work.

I'm going to reload /psp/parameters.ini every time GetParam or SetParam is called in firmware 22.
There is also a new command GetParams for your convenience.

You can safely substitute your /usr/bin/NeTVServer with the latest binary here
It shouldn't break any of your existing code. Remember to chmod +x

Btw, I don't know what your 'boxid' is, but there is a unique GUID for each device in 'hello' command. Just a suggestion.

Re: Having trouble with GETPARAM

Here is what we are trying to do -

We need to uniquely identify each box with an ID into a database.  We have switched to the GUID funtion and that works.  We've built a script that generates it and we pipe that result into a txt.

We can't seem to find a way to read that value into JS.  It becomes an argument to our server. (right now hard coded at 1).  We even tried to create a guid.js file that would return the value, but could not get the web page to read that in as script source.

We're a little stuck at the moment trying to solve this.  I need a little JS snippet that will return a string that is the GUID that I can tack on as a parameter to a server call using XMLhttpRequest call.  We have server that can take the argument on the passed url and return XML.  We are happily parsing that XML and all is grand.  Just can't get the darned GUID to move through.

Below is the the function -  You will notice the boxid=1.  That's what we want to make unique to each box.

function poll()
    xmlhttp=new XMLHttpRequest();"GET","schedule.php?boxid=1",false);
    if (xmlDoc.getElementsByTagName("action")[0].childNodes[0].nodeValue == "goto") {
    if (xmlDoc.getElementsByTagName("action")[0].childNodes[0].nodeValue == "download") {
        var fname=xmlDoc.getElementsByTagName("fname")[0].childNodes[0].nodeValue;
        xmlhttpdl=new XMLHttpRequest();"GET","http://localhost/scripts/"+fname,false);



Re: Having trouble with GETPARAM

You can take a look at the recommended way to issue a Hello command & assign a callback to catch the result in

You can call your poll() function in helloCallback. helloData['guid'] is what you want.

The way that you are doing it here seems frisky to me, especially when your server is a real online server, not localhost.
It is better to do this asynchronously & not freeze the UI.

Re: Having trouble with GETPARAM

even tried the following -
    <script type="text/javascript" src="http://localhost/scripts/guid.js"></script>

where guid.js is a file we built on the fly to return the guid as a function call.

function getguid() {return ("169C9111-D428-6B2E-9D72-5530FFCE8B27");}

no go.  don't think script include works.  We noticed that when the url is called it does something different than most webservers.  normally you just get the text of the JS files.  with netv it tries to down load the file and fails.

6 (edited by torinnguyen 2011-11-02 07:58:56)

Re: Having trouble with GETPARAM

Wow! This is unexpected.
I thought you were asking for CGI-BIN like stuff, so I assumed you were asking for perl or shell scripts.
The script support feature is never meant for JavaScript.

Here's what you need to do:
1) create in /usr/share/netvserver/docroot/scripts
The content is just 2 lines:

2) make sure it is executable
chmod +x /usr/share/netvserver/docroot/scripts/

3) execute it (not include it) as

If it gives you blank value, check step (2)

To explain why your simple include failed.
http://localhost/scripts is specially handled by NeTVServer to execute shell scripts, it will not work if you host JavaScript files in there.

Re: Having trouble with GETPARAM

We reached a similar conclusion.  We decided to pull all the polling and scheduling stuff out of JS and move it into shell scripts. 

We were jumping through to many hoops and were running into reliability issues.

So, when JS needs to poll (and we will move this to cron later). it calls a shell script.  that script has all the info it needs (guid etc.)

works great and is much more reliable.

thanks as always for your help.