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, a command, and an 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.

 

Note

 

For tasks after login, 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 first 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. To create a task, create a new TelnetTask instance with a start prompt, command, and an end prompt as arguments to its constructor.

 

Example

This example, the start prompt, command, and end prompt string values are explicitly passed.

 

[C#]

// Create telnet instance

Telnet telnet = new Telnet("10.0.0.1");

// Create TelnetScript script instance by passing in telnet instance

TelnetScript script = new TelnetScript(telnet);

 

// Create TelnetTask cd by passing start prompt, command, and end prompt

TelnetTask cd = new TelnetTask("$", "cd /", "$");

// Create TelnetTask dir by passing start prompt, command, and end prompt

TelnetTask dir = new TelnetTask("$", "ls -al", "$");

 

// Add tasks cd and dir to script instance

script.AddTask(cd);

script.AddTask(dir);

 

 

[Visual Basic]

Private WithEvents myTelnet As Telnet

' Create telnet instance

myTelnet = New Telnet("10.0.0.1")

 

' Create TelnetScript script instance by passing in telnet instance

Dim script As TelnetScript = New TelnetScript(myTelnet)

 

' Create TelnetTask cd by passing start prompt, command, and end prompt

Dim cd As TelnetTask = New TelnetTask("$", "cd /", "$")

' Create TelnetTask dir by passing start prompt, command, and end prompt

Dim dir As TelnetTask = New TelnetTask("$", "ls -al", "$")

 

' Add tasks cd and dir to script instance

script.AddTask(cd)

script.AddTask(dir)





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

© 2021 JSCAPE LLC