Using regular expressinos

Top  Previous  Next

In some situations you may find that the start or end prompts for a TelnetTask are difficult to define. This is especially true in cases where the prompts may change based on the user or system.

 

To address this issue regular expressions may be optionally used when defining the start and end prompts for a TelnetTask. To define a prompt as a regular expression first define the prompts and then use the StartPromptRegex and EndPromptRegex properties to define the start and end prompts of the TelnetTask as regular expressions. While a TelnetTask is running it will use this information to determine whether the data returned by the server should be evaluated using a string comparison match or regular expression match.

 

Note

 

Refer to the Visual Studio .NET documentation for more information about constructing regular expressions.

 

 

Example

In the following example both the start and end prompts are defined as regular expressions. In the case of the start prompt the TelnetTask will wait for the text "login:" or "Login:" to be returned by the server before sending the username "jsmith". It will then wait for the prompt "Password:" or "password:" before considering this TelnetTask as complete and moving on to the next TelnetTask.

 

[C#]

// define task

TelnetTask loginTask = new TelnetTask("[Ll]ogin:","jsmith","[Pp]assword:");

loginTask.StartPromptRegex = true;

loginTask.EndPromptRegex = true;

 

 

[Visual Basic]

' define task

Dim loginTask As TelnetTask = New TelnetTask("[Ll]ogin:", "jsmith", "[Pp]assword:")

loginTask.StartPromptRegex = True

loginTask.EndPromptRegex = True





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

© 2021 JSCAPE LLC