/console URL Handler (In-Process CGI Task)

URL Handler (In-Process CGI routine) that executes a GPL console command and returns the string value for use in a web page.

/console

Prerequisites

None

AJAX Send Request (XMLHttpRequest) Parameters

.Open("POST", "/console", false)

A required AJAX method that specifies the type of request, the URL, and if the request should be handled asynchronously or not.  For this operation, the method must be "POST", the url must be "/console", and async must be false to synchronize the reading of the RPC results.

.SetRequestHeader("Content-type", type)

A required AJAX method that defines the format of the reply.  The type should be set to "text/plain" for general compatibility.

.Send(string)

A required AJAX method that specifies the Console Command to be executed along with any required arguments.  Since GPL requires double quotes around String constants, the string should contain the following fields surrounded by single quotes as follows:

'command arg1 ... argn'

where

Remarks

This method permits standard GPL Console Commands to be issued from web pages using an HTML POST operation to the special URL named "/console". The contents of the POST are interpreted by the GPL web server as a command. One way to issue the POST is by using AJAX to issue the POST and read the response.

As compared to the aspConsole server side Javascript procedure that embeds its response text in the web page, this method permits the response to be copied to a JavaScript variable for additional processing on the client.

With regard to the response text:

DataID 464 has no effect on the remote console commands. Commands are hard-coded to time-out in 30 seconds.

Examples

Here is an example AJAX script containing the console command "show version":

var xmlHttpOprStt
function CommandTest() {
xmlHttpOprStt=new XMLHttpRequest();
xmlHttpOprStt.open("POST","/console",false);
xmlHttpOprStt.setRequestHeader("Content-type","text/plain");
xmlHttpOprStt.send('show version');
return xmlHttpOprStt.responseText
}

After execution, the function returns a string containing:

    Controller model G2400<lf>GPL 3.2G5, Oct 17 2012, Beta 
Release<lf>RTOS-4.6.1(PowerPC/PowerPC 603e/ids5200) Apr 3
2009<lf>Configuration: RTC, Options: RTC<lf>0,"Success"<lf>

where: <lf> represents the line-feed character.

See Also

Web Dictionary Summary | aspGPL| aspConsole | /rpcURL Handler