The Telnet Connector is used to execute commands on a remote host by means of the Telnet protocol.

Features

  • Based on Standardized Telnet Protocol
  • Password based authentication mechanism
  • Serial execution of commands specified in simplified comma separated format with prompts
  • Direct access to the command execution results from the remote server machine
  • Ability to set timeouts for connector execution
  • Synchronous / Asynchronous execution of the Connector

Connector Configuration

add_telnet_connector

Configuration parameters- config(JSON)
ParameterDescriptionRequired
targetHost name or ip-address of the remote machine you wish to connect totrue: config/request
usernameUsername which will be used to log into remote machine, required for authenticationtrue: config/request
passwordPassword associated with the username specified, required for authenticationfalse: config/request
portPort to connect to on the remote machine. Default value is 23false: config/request
Example
{
  "target": "192.168.2.64",
  "username": "daniel",
  "password": "daniel123",
  "port": 23 
} 

Actions

exec

Run command on remote machine using password based authentication

Request parameters

ParameterDescriptionRequired
connector_nameName of the Telnet Connector to be configuredtrue
targetHost name or ip-address of the remote machine you wish to connect totrue
usernameUsername which will be used to log into remote machine, required for authenticationtrue
username-promptPrompt coming before enter username to connecttrue
passwordPassword associated with the username specified, required for authenticationtrue
password-promptPrompt coming before enter password to connecttrue
commandCommand to be executed on the host server machine with expected prompttrue
timeoutTimeout in milliseconds, taken by the connector to serve the telnet request. Default timeout is 60,000 msfalse

Response parameters

ParameterDescriptionRequired
resultResults as per the command executedtrue

Example

response=@call.connector("my-telnet-connector")
              .set("target","192.168.2.64")
              .set("username","daniel")
			  .set("username-prompt","login: ")
              .set("password","daniel123")
			  .set("password-prompt","password: ")
              .set("command",[">","enable","Password: ","daniel123","#","exit"])
              .set("timeout",60000)
              .sync

#Telnet Connector Response Parameters
result=response.get("result")                    #Result

Note

Command, is an combination of command prompts and commands to be executed. Its an array, where values for prompts and commands must be provided alternatively in series.

Example of using prompt and command

.set("command",[">","enable","Password: ","daniel123","#","exit"])
where, ">" - prompt
"enable" - actual command
"Password:" - prompt
"daniel123" - actual password required for 'enable' command

Connector request error handling

This is how success or failures can be handled for the connector requests within your Flintbit. This would help to take appropriate action if something failed.

if response.exitcode == 0               # 0 is success.
  @log.info("success")
  # take action in case of success
else                                    # non zero means fail
  @log.error("fail")
  @log.trace("Reason:" + response.message)     # get the reason of failure
  ## Take action in case of failure
end

 

On this page: