popen
Popen - a process enabling iRidium Server to execute a command in the Windows and Linux command string. Popen does not work in the i3 pro client application. Executing of Popen opens the file directory of the process and allows you to sent information about command work in the indicated instance of the listener function. In order to execute several commands and distinguish information about their work, create Popen instances.
Syntax
var cmd_process = new Popen (command, function);
input | value | description |
command | 'ping 192.168.0.1' | type: string the command for execution in the command string (cmd.exe) |
function | cmd_result | type: function the instance of the listener function where the results of command execution will be sent |
output |
|
|
line | .onRecieve | type: string the data generated by the command during execution. The .OnReceive event is activated in the context of Popen and receives the line string as an input parameter. The string can be output in the log or written in the iRidium Server variable |
result | .onEnd | type: number the code generated by the command at its finishing. The .onEnd event is activated in the context of Popen and result is received as an input parameter. You can output the code in the log or write in the iRidium Server variable:
|
.Stop() | .Stop() | type: method the command of forced finish of the Popen process. You do not need to finish the process if the .onEnd event is activated. But you are required to finish it when the command does not finish (for example, as continuous ping) |
Sample
function Listener (cmd) { this.onRecieve = function(line) { IR.Log(line); } this.onEnd = function(result) { IR.Log('Command: '+ cmd + " Result: " + result); } } function stop() { cmd_process.Stop(); } var cmd_result = new Listener ('ping 192.168.0.1'); var cmd_process = new Popen ('ping 192.168.0.1', cmd_result);
To finish the process use the Stop() method. Command which do not finish by themselves must be stopped as each of them uses OS resources and affects speed of operation
Popen works only in iRidium Server on Windows and Linux. It does not work in i3 proCustomer support service by UserEcho