Telnet & TCP
Drive legacy devices over raw Telnet or TCP.
See TCP driver examples on GitHub (Telnet examples in the sibling folder).
D.device.sendTCPCommand
Section titled “D.device.sendTCPCommand”Sends a command to the device via TCP.
Signature
D.device.sendTCPCommand(options, callback)Parameters
options· `Object`- The TCP Command execution options
options.command· `string`- The tcp command to execute against the device
options.port· `int` · optional, default `23`- The tcp port to connect to
options.timeout· `int` · optional, default `500`- The time the tcp command will execute for at most (in milliseconds)
options.keepAlive· `boolean` · optional- Boolean flag to use if the TCP connection should persist until the timeout value runs out. Disabled by default
options.encoding· `str` · optional, default `utf8`- The tcp command response encoding. Default 'utf8'
callback· `function`- The TCP Command execution callback function
callback.output· `string`- The Result from the tcp command execution
callback.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
Returns
void
Example
D.device.sendTCPCommand(options, callback)D.device.sendTelnetCommand
Section titled “D.device.sendTelnetCommand”Sends a command to the device via Telnet.
Signature
D.device.sendTelnetCommand(options, callback)Parameters
options· `Object`- The Telnet Command execution options
options.command· `string`- The telnet command to execute against the device
options.port· `int` · optional, default `23`- The telnet port to connect to
options.timeout· `int` · optional, default `500`- The time the telnet session will persist for (in milisenconds)
options.negotiationMandatory· `boolean` · optional- Set this to true if the telnet session requires authentication
options.shellPrompt· `string` · optional, default `/(?:\/ )?#\s/`- The expected shell prompt regular expression for the telnet session
options.loginPrompt· `string` · optional, default `/login[: ]*$/i`- The expected username prompt regular expression for the telnet session
options.passwordPrompt· `string` · optional, default `/Password: /i`- The expected password prompt regular expression for the telnet session
callback· `function`- The Telnet Command execution callback function
callback.output· `string`- The Result from the telnet command execution
callback.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
Returns
void
Example
D.device.sendTelnetCommand(options, callback)