The TelnetServer component is used to connect to and send commands to a Telnet server.
To connect to a telnet server you must specify host, password, port and prompt. The prompt value is needed to detect command output termination accurately.
The following example connects to the server, changes the prompt and invokes some commands.
user = "example_user"
host = "example_host"
connectTo TelnetServer
using host = host,
port = 23,
user = user,
password = "example_password",
prompt = user + "@" + host
commandResult as String
// Setting prompt to a constant value (working directory is not included)
commandResult = sendCommandTo(TelnetServer, command : "export PS1=\"\\u@\\h>\"")
TelnetServer.prompt = user + "@" + host + ">"
commandResult = sendCommandTo(TelnetServer, command : "ls -la")
display commandResult
commandResult = sendCommandTo(TelnetServer, command : "pwd")
display commandResult