<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Scripting</title><link>https://sourceforge.net/p/openacs/wiki/Scripting/</link><description>Recent changes to Scripting</description><atom:link href="https://sourceforge.net/p/openacs/wiki/Scripting/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 22 Apr 2015 12:34:50 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/openacs/wiki/Scripting/feed" rel="self" type="application/rss+xml"/><item><title>Discussion for Scripting page</title><link>https://sourceforge.net/p/openacs/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;hello wiki&lt;br /&gt;
my openacs can found easycwmp,but I can not found easycwmp value tree,and can upgrade data in db,can you help me out on this?thank you!&lt;/p&gt;&lt;/div&gt;</description><pubDate>Wed, 22 Apr 2015 12:34:50 -0000</pubDate><guid>https://sourceforge.net649c3330f1c3890c73dc2e77611f7469f1bc800b</guid></item><item><title>Scripting modified by &lt;REDACTED&gt;</title><link>https://sourceforge.net/p/openacs/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;/div&gt;</description><pubDate>Fri, 08 Nov 2013 17:53:39 -0000</pubDate><guid>https://sourceforge.net78f23b803f447d48359318ceff419fe2fecc1305</guid></item><item><title>Scripting modified by &lt;REDACTED&gt;</title><link>https://sourceforge.net/p/openacs/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -210,7 +210,7 @@
 To run INSERT or UPDATE queries use Update function.

 ~~~~
-db.Update (data_source_name, select_statement)
+db.Update (data_source_name, update_statement)
 ~~~~

 This would run query on openacs datasource "java:ACS".
&lt;/pre&gt;
&lt;/div&gt;</description><pubDate>Wed, 10 Apr 2013 11:22:21 -0000</pubDate><guid>https://sourceforge.nete57fedc8cc7032fafa0ad21144b91a8c4eb5b349</guid></item><item><title>WikiPage Scripting modified by &lt;REDACTED&gt;</title><link>https://sourceforge.net/p/openacs/wiki/Scripting/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -161,7 +161,15 @@
 var status = response.Status; // status - 0 if succes
 ~~~~~

-
+**SyncParameterValues** - check and synchronize parameter values on cpe.
+
+~~~~~
+var parameters = new Array ();
+parameters[0] = {Name: 'InternetGatewayDevice.ManagementServer.PeriodicInformEnable', Value: '1'};
+parameters[1] = {Name: 'InternetGatewayDevice.ManagementServer.PeriodicInformInterval', Value: '300'};
+cpe.SyncParameterValues (parameters);
+~~~~~
+ 
 ####db####

 This object allows to work with database. The database can be the same the openacs uses to store data as well as external datasource configured similar to datasource in [1] step 3
&lt;/pre&gt;
&lt;/div&gt;</description><pubDate>Wed, 27 Mar 2013 17:53:08 -0000</pubDate><guid>https://sourceforge.net3b5ed23f7c5e0bad5417766c996d8d33939c7fa6</guid></item><item><title>WikiPage Scripting modified by &lt;REDACTED&gt;</title><link>https://sourceforge.net/p/openacs/wiki/Scripting/</link><description>&lt;pre&gt;--- v2
+++ v3
@@ -47,6 +47,7 @@
 **Inform** - exposes Inform request which triggered configuration script to run.
  
 #####Methods#####
+
 **GetRPCMethods ()** - return arrays of methods supported by CPE. 
 
 ~~~~
@@ -57,12 +58,14 @@
 }
 ~~~~
  
+
 **Download (commandKey, what_to_download, url, username, password, file_size, file_name)** - Tells CPE to start downloading configuration or firmware depending on what_to_download parameter (possible values as specified in TR-069)
 
 ~~~~
 var response = cpe.Download ("daCommand", "3 Vendor Configuration File","http://192.168.1.1:8080/kkonf", "", "",000,"user.ini");
 logger ("st="+response.StartTime+" ct="+CompleteTime+" status="+response.Status);
 ~~~~~
+
 
 **GetParameterValues (array_of_parameter_names)** - return array of object with properties *name* and *value*.
 
@@ -72,6 +75,7 @@
 var response = cpe.GetParameterValues (parameters);
 logger (response[0].name+'='+response[0].value);
 ~~~~~
+
 
 **SetParameterValues (params_array, commandKey)** - sets parameter values. Params_array is array of objects having properties *name* and *value*.
 
@@ -85,13 +89,16 @@
 cpe.SetParameterValues (parameters, "commandKey");
 ~~~~
  
+
 **AddObject (top_object_name, parameterKey)** - creates new object instance. Returns object with properties *Status* and *InstanceNumber*.
  
+
 **DeleteObject (object_name, parameterKey)** - delete object. Returns integer status.
 
+
 **SetParameterAttributes (params_array)** - set attributes for parameters. Returns nothing.
 
-~~~
+~~~~
 var parameters = new Array();
 parameters[0]=new Object;
 parameters[0].Name='InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions';
@@ -103,6 +110,7 @@
 cpe.SetParameterAttributes (parameters);
 ~~~~~
  
+
 **GetParameterAttributes (parameter_names_array)**
 
 ~~~~~
@@ -111,23 +119,27 @@
 var r = cpe.GetParameterAttributes (p);
 ~~~~
  
+
 **Reboot (commandKey)** - reboots cpe. 
 
 ~~~~
 cpe.Reboot ("commandKey");
 ~~~~
 
+
 **FactoryReset** - resets cpe to factory default settings. Method is optional in cpe so not all of them has support for it.
 
-~~~
+~~~~
 cpe.FactoryReset ();
 ~~~~
 
+
 **ScheduleInform (seconds_to_delay, commandKey)** - request the CPE to schedule a one-time Inform method call (separate from its periodic Inform method calls) sometime in the future. Method is optional in cpe so not all of them has support for it.
 
 ~~~~
 cpe.ScheduleInform (3600, "commandKey"); // schedule inform in one hour
 ~~~~
+
 
 **X_00000C_ShowStatus (array_of_show_commands)** - Cisco proprietary method to run several show commands and get their output.
 
@@ -140,6 +152,7 @@
 var itsoutput = response [0].Response;
 ~~~~
 
+
 **X_JUNGO_COM_RGCommand (telnet_command)** - jungo.com OpenRG based firmware proprietary method to run command.
 
 ~~~~~
@@ -148,6 +161,7 @@
 var status = response.Status; // status - 0 if succes
 ~~~~~
  
+
 ####db####
  
 This object allows to work with database. The database can be the same the openacs uses to store data as well as external datasource configured similar to datasource in [1] step 3
&lt;/pre&gt;</description><pubDate>Thu, 09 Aug 2012 08:33:47 -0000</pubDate><guid>https://sourceforge.net50d583bbec4d1c699107af757dae74807cf7f654</guid></item><item><title>WikiPage Scripting modified by &lt;REDACTED&gt;</title><link>https://sourceforge.net/p/openacs/wiki/Scripting/</link><description>&lt;pre&gt;--- v1
+++ v2
@@ -6,67 +6,93 @@
 Functions
 -------------
  
-*logger*
+####logger####
  
 Function provides access to standard application server logger facility. 
+
+~~~~~
 logger ('My message'); // message with default severity WARNING is logged.
 logger ('severe', 'Error message');
 logger ('warning', 'Warning message');
 logger ('info', 'Informational message');
- 
-*call*
+~~~~~~
+ 
+
+####call####
  
 Function lets to run another script. 
+
+~~~~~
 call ('script_name');
+~~~~~
  
 Variables
 ------
  
-*cpedb*
+####cpedb####
  
 cpedb global variable provides acces to CPE bean in database, namely to properties field. They can be accessed as usual javascript properties. To save them back to database method Save should be used. This object is intended to assign configuration properties for user.
- var someprop = cpedb.someprop;
+
+~~~~
+var someprop = cpedb.someprop;
 cpedb.someprop = 'new_value_for_someprop';
 cpedb.Save ();
- 
-*cpe*
+~~~~
+ 
+####cpe####
  
 cpe global variable provides access to all the CPE variables and RPC calls specified in TR-069.
  
-Properties Inform - exposes Inform request which triggered configuration script to run.
- 
-Methods GetRPCMethods () - return arrays of methods supported by CPE. 
+#####Properties#####
+**Inform** - exposes Inform request which triggered configuration script to run.
+ 
+#####Methods#####
+**GetRPCMethods ()** - return arrays of methods supported by CPE. 
+
+~~~~
 // this will output supported methods to server console
 var methods = cpe.GetRPCMethods ();
 for (i = 0; i &lt; methods.length; i++) {
        logger ('Method: '+methods[i]);
 }
- 
-Download (commandKey, what_to_download, url, username, password, file_size, file_name) - Tells CPE to start downloading configuration or firmware depending on what_to_download parameter (possible values as specified in TR-069)
- var response = cpe.Download ("daCommand", "3 Vendor Configuration File","http://192.168.1.1:8080/kkonf", "", "",000,"user.ini");
+~~~~
+ 
+**Download (commandKey, what_to_download, url, username, password, file_size, file_name)** - Tells CPE to start downloading configuration or firmware depending on what_to_download parameter (possible values as specified in TR-069)
+
+~~~~
+var response = cpe.Download ("daCommand", "3 Vendor Configuration File","http://192.168.1.1:8080/kkonf", "", "",000,"user.ini");
 logger ("st="+response.StartTime+" ct="+CompleteTime+" status="+response.Status);
- 
-GetParameterValues (array_of_parameter_names) - return array of object with properties //name// and //value//.
- var parameters = new Array ();
+~~~~~
+
+**GetParameterValues (array_of_parameter_names)** - return array of object with properties *name* and *value*.
+
+~~~~
+var parameters = new Array ();
 parameters[0] = 'InternetGatewayDevice.DeviceSummary';
 var response = cpe.GetParameterValues (parameters);
 logger (response[0].name+'='+response[0].value);
- 
-SetParameterValues (params_array, commandKey) - sets parameter values. Params_array is array of objects having properties //name// and //value//.
- var parameters = new Array ();
+~~~~~
+
+**SetParameterValues (params_array, commandKey)** - sets parameter values. Params_array is array of objects having properties *name* and *value*.
+
+~~~~
+var parameters = new Array ();
 parameters[0] = {name: 'InternetGatewayDevice.IPPingDiagnostics.Host', value: '192.168.0.1'};
 // Encode parameter using default type xsd:string
 parameters[1] = {name: 'InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions', value: '2'};
 // set encoding type
 parameters[2] = {name: 'InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions', value: '2', type: 'xsd:unsignedInt'};
 cpe.SetParameterValues (parameters, "commandKey");
- 
-AddObject (top_object_name, parameterKey) - creates new object instance. Returns object with properties //Status// and //InstanceNumber.//
- 
-DeleteObject (object_name, parameterKey) - delete object. Returns integer status.
- 
-SetParameterAttributes (params_array) - set attributes for parameters. Returns nothing.
- var parameters = new Array();
+~~~~
+ 
+**AddObject (top_object_name, parameterKey)** - creates new object instance. Returns object with properties *Status* and *InstanceNumber*.
+ 
+**DeleteObject (object_name, parameterKey)** - delete object. Returns integer status.
+
+**SetParameterAttributes (params_array)** - set attributes for parameters. Returns nothing.
+
+~~~
+var parameters = new Array();
 parameters[0]=new Object;
 parameters[0].Name='InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions';
 parameters[0].Notification=0;
@@ -75,48 +101,79 @@
 parameters[0].AccessList= new Array ();
 parameters[0].AccessList[0]='subscriber';
 cpe.SetParameterAttributes (parameters);
- 
-GetParameterAttributes (parameter_names_array). 
+~~~~~
+ 
+**GetParameterAttributes (parameter_names_array)**
+
+~~~~~
 var p=new Array(); 
 p[0]='InternetGatewayDevice.ManagementServer.PeriodicInformEnable'; 
 var r = cpe.GetParameterAttributes (p);
- 
-Reboot (commandKey) - reboots cpe. 
+~~~~
+ 
+**Reboot (commandKey)** - reboots cpe. 
+
+~~~~
 cpe.Reboot ("commandKey");
- 
-FactoryReset - resets cpe to factory default settings. Method is optional in cpe so not all of them has support for it.
- cpe.FactoryReset ();
- 
-ScheduleInform (seconds_to_delay, commandKey) - request the CPE to schedule a one-time Inform method call (separate from its periodic Inform method calls) sometime in the future. Method is optional in cpe so not all of them has support for it.
- cpe.ScheduleInform (3600, "commandKey"); // schedule inform in one hour
- 
-X_00000C_ShowStatus (array_of_show_commands) - Cisco proprietary method to run several show commands and get their output.
- var commands = new Array ();
+~~~~
+
+**FactoryReset** - resets cpe to factory default settings. Method is optional in cpe so not all of them has support for it.
+
+~~~
+cpe.FactoryReset ();
+~~~~
+
+**ScheduleInform (seconds_to_delay, commandKey)** - request the CPE to schedule a one-time Inform method call (separate from its periodic Inform method calls) sometime in the future. Method is optional in cpe so not all of them has support for it.
+
+~~~~
+cpe.ScheduleInform (3600, "commandKey"); // schedule inform in one hour
+~~~~
+
+**X_00000C_ShowStatus (array_of_show_commands)** - Cisco proprietary method to run several show commands and get their output.
+
+~~~~~
+var commands = new Array ();
 commands [0] = "show version";
 commands [1] = "show running";
 var response = cpe.X_00000C_ShowStatus (commands);
 var thecommand = response [0].Command;
 var itsoutput = response [0].Response;
- 
-X_JUNGO_COM_RGCommand (telnet_command) - jungo.com OpenRG based firmware proprietary method to run command.
- var response = cpe.X_JUNGO_COM_RGCommand ("net ifconfig");
+~~~~
+
+**X_JUNGO_COM_RGCommand (telnet_command)** - jungo.com OpenRG based firmware proprietary method to run command.
+
+~~~~~
+var response = cpe.X_JUNGO_COM_RGCommand ("net ifconfig");
 var result = response.Result; // output of command
 var status = response.Status; // status - 0 if succes
- 
-[edit] db
+~~~~~
+ 
+####db####
  
 This object allows to work with database. The database can be the same the openacs uses to store data as well as external datasource configured similar to datasource in [1] step 3
  
 This would run SELECT query on datasource named the data_source_name.
- db.Query (data_source_name, select_statement)
+
+~~~~
+db.Query (data_source_name, select_statement)
+~~~~
  
 
 This would run query on openacs datasource "java:ACS".
- db.Query (select_statement) 
-it is equivalent to db.Query ("java:ACS", select_statement)
- 
+
+~~~~
+db.Query (select_statement) 
+~~~~
+
+it is equivalent to 
+
+~~~~
+db.Query ("java:ACS", select_statement)
+~~~~
 
 returns array of objects with fields name as in query e.g. 
+
+~~~~
 try {
 	var rs = db.Query ("SELECT id,serialno FROM hostsbean")
 	logger ("Rows found = "+rs.length)
@@ -126,18 +183,26 @@
 } catch (e) {
 	logger ("DS exception: "+e.message)
 }
+~~~~
  
 To run INSERT or UPDATE queries use Update function.
- db.Update (data_source_name, select_statement)
- 
+
+~~~~
+db.Update (data_source_name, select_statement)
+~~~~
 
 This would run query on openacs datasource "java:ACS".
- db.Update (select_statement) 
-
+
+~~~~
+db.Update (select_statement) 
+~~~~
 
 returns count of rows affected e.g. 
+
+~~~~
 try {
 	var rs = db.Update ("INSERT id,serialno INTO hostsbean VALUES (NULL,'12345')")
 } catch (e) {
 	logger ("DS exception: "+e.message)
 }
+~~~~
&lt;/pre&gt;</description><pubDate>Thu, 09 Aug 2012 08:29:21 -0000</pubDate><guid>https://sourceforge.netd28bd8bfbc88d45bbef04ae8e10bc6093d79ed49</guid></item><item><title>WikiPage Scripting modified by &lt;REDACTED&gt;</title><link>https://sourceforge.net/p/openacs/wiki/Scripting/</link><description>Configurations script
----------
 
OpenACS supports configuration scripts written in JavaScript. If you want to use scripts to configure CPE you must have a script named 'Default' because this is the script the server will try to run on CPE Inform request when it has no configuration files or firmware update requests pending .
 
Functions
-------------
 
*logger*
 
Function provides access to standard application server logger facility. 
logger ('My message'); // message with default severity WARNING is logged.
logger ('severe', 'Error message');
logger ('warning', 'Warning message');
logger ('info', 'Informational message');
 
*call*
 
Function lets to run another script. 
call ('script_name');
 
Variables
------
 
*cpedb*
 
cpedb global variable provides acces to CPE bean in database, namely to properties field. They can be accessed as usual javascript properties. To save them back to database method Save should be used. This object is intended to assign configuration properties for user.
 var someprop = cpedb.someprop;
cpedb.someprop = 'new_value_for_someprop';
cpedb.Save ();
 
*cpe*
 
cpe global variable provides access to all the CPE variables and RPC calls specified in TR-069.
 
Properties Inform - exposes Inform request which triggered configuration script to run.
 
Methods GetRPCMethods () - return arrays of methods supported by CPE. 
// this will output supported methods to server console
var methods = cpe.GetRPCMethods ();
for (i = 0; i &lt; methods.length; i++) {
       logger ('Method: '+methods[i]);
}
 
Download (commandKey, what_to_download, url, username, password, file_size, file_name) - Tells CPE to start downloading configuration or firmware depending on what_to_download parameter (possible values as specified in TR-069)
 var response = cpe.Download ("daCommand", "3 Vendor Configuration File","http://192.168.1.1:8080/kkonf", "", "",000,"user.ini");
logger ("st="+response.StartTime+" ct="+CompleteTime+" status="+response.Status);
 
GetParameterValues (array_of_parameter_names) - return array of object with properties //name// and //value//.
 var parameters = new Array ();
parameters[0] = 'InternetGatewayDevice.DeviceSummary';
var response = cpe.GetParameterValues (parameters);
logger (response[0].name+'='+response[0].value);
 
SetParameterValues (params_array, commandKey) - sets parameter values. Params_array is array of objects having properties //name// and //value//.
 var parameters = new Array ();
parameters[0] = {name: 'InternetGatewayDevice.IPPingDiagnostics.Host', value: '192.168.0.1'};
// Encode parameter using default type xsd:string
parameters[1] = {name: 'InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions', value: '2'};
// set encoding type
parameters[2] = {name: 'InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions', value: '2', type: 'xsd:unsignedInt'};
cpe.SetParameterValues (parameters, "commandKey");
 
AddObject (top_object_name, parameterKey) - creates new object instance. Returns object with properties //Status// and //InstanceNumber.//
 
DeleteObject (object_name, parameterKey) - delete object. Returns integer status.
 
SetParameterAttributes (params_array) - set attributes for parameters. Returns nothing.
 var parameters = new Array();
parameters[0]=new Object;
parameters[0].Name='InternetGatewayDevice.IPPingDiagnostics.NumberOfRepetitions';
parameters[0].Notification=0;
parameters[0].NotificationChange=true;
parameters[0].AccessListChange=true;
parameters[0].AccessList= new Array ();
parameters[0].AccessList[0]='subscriber';
cpe.SetParameterAttributes (parameters);
 
GetParameterAttributes (parameter_names_array). 
var p=new Array(); 
p[0]='InternetGatewayDevice.ManagementServer.PeriodicInformEnable'; 
var r = cpe.GetParameterAttributes (p);
 
Reboot (commandKey) - reboots cpe. 
cpe.Reboot ("commandKey");
 
FactoryReset - resets cpe to factory default settings. Method is optional in cpe so not all of them has support for it.
 cpe.FactoryReset ();
 
ScheduleInform (seconds_to_delay, commandKey) - request the CPE to schedule a one-time Inform method call (separate from its periodic Inform method calls) sometime in the future. Method is optional in cpe so not all of them has support for it.
 cpe.ScheduleInform (3600, "commandKey"); // schedule inform in one hour
 
X_00000C_ShowStatus (array_of_show_commands) - Cisco proprietary method to run several show commands and get their output.
 var commands = new Array ();
commands [0] = "show version";
commands [1] = "show running";
var response = cpe.X_00000C_ShowStatus (commands);
var thecommand = response [0].Command;
var itsoutput = response [0].Response;
 
X_JUNGO_COM_RGCommand (telnet_command) - jungo.com OpenRG based firmware proprietary method to run command.
 var response = cpe.X_JUNGO_COM_RGCommand ("net ifconfig");
var result = response.Result; // output of command
var status = response.Status; // status - 0 if succes
 
[edit] db
 
This object allows to work with database. The database can be the same the openacs uses to store data as well as external datasource configured similar to datasource in [1] step 3
 
This would run SELECT query on datasource named the data_source_name.
 db.Query (data_source_name, select_statement)
 

This would run query on openacs datasource "java:ACS".
 db.Query (select_statement) 
it is equivalent to db.Query ("java:ACS", select_statement)
 

returns array of objects with fields name as in query e.g. 
try {
	var rs = db.Query ("SELECT id,serialno FROM hostsbean")
	logger ("Rows found = "+rs.length)
	for (i=0; i &lt; rs.length; i++) {
		logger ("id = "+rs[i].id+" serialno= "+rs[i].serialno);
	}
} catch (e) {
	logger ("DS exception: "+e.message)
}
 
To run INSERT or UPDATE queries use Update function.
 db.Update (data_source_name, select_statement)
 

This would run query on openacs datasource "java:ACS".
 db.Update (select_statement) 


returns count of rows affected e.g. 
try {
	var rs = db.Update ("INSERT id,serialno INTO hostsbean VALUES (NULL,'12345')")
} catch (e) {
	logger ("DS exception: "+e.message)
}
</description><pubDate>Thu, 09 Aug 2012 08:16:41 -0000</pubDate><guid>https://sourceforge.netc845f63e90119fb5ed5a4ec99c055c99fc357013</guid></item></channel></rss>