Creating a task

Top  Previous  Next

A task is a procedure to execute on the telnet server. A TelnetTask instance represents a procedure to be executed on the telnet server.

 

Each TelnetTask contains a start prompt, command and end prompt. The start prompt is the data returned by the Telnet server to indicate when the task may begin execution. The command is the command to execute on the Telnet server. The end prompt is data returned by the telnet server used to indicate when the task has completed.

 

To create a task, create a new TelnetTask instance with a start prompt, command and end prompt as its arguments. The start prompt and end prompt usually represent the shell prompt that is displayed to the user when logging into a telnet server interactively.

 

For a TelnetTask to be considered for execution it must belong to a TelnetScript . This can be done using the TelnetScript#addTask method. All TelnetTask are executed in the order they are added to the TelnetScript .

 

Example

 

// create new TelnetScript  

TelnetScript script = new TelnetScript(telnet);

 

// create a task that waits for login prompt and submits username

TelnetTask username = new TelnetTask("login:","jsmith","Password:");

 

// create task that waits for password prompt and submits password

TelnetTask password = new TelnetTask("Password:","secret","$");

 

// add tasks to script

script.addTask(username);

script.addTask(password);





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC