Checking for task completion

Top  Previous  Next

To check to see if a task has completed invoke the TelnetTask.IsComplete method.

 

Example

 

[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 sh_exec by passing start prompt, command, and end prompt

TelnetTask sh_exec = new TelnetTask("$", "run.sh", "$");

 

// Add tasks sh_exec to script instance

script.AddTask(sh_exec);

 

// Connect to telnet server, automatically executing the script

telnet.Connect();

 

if (sh_exec.IsComplete) {

 Console.WriteLine("Completed");

}

// Disconnect

telnet.Disconnect();

 

 

[Visual Basic]

' Create telnet instance

Dim telnet As Telnet = New Telnet("10.0.0.1")

' Create TelnetScript script instance by passing in telnet instance

Dim script As TelnetScript = New TelnetScript(telnet)

 

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

Dim sh_exec As TelnetTask = New TelnetTask("$", "run.sh", "$")

 

' Add tasks sh_exec to script instance

script.AddTask(sh_exec)

 

' Connect to telnet server, automatically executing the script

telnet.Connect()

 

While Not sh_exec.IsComplete()

  Try

       Thread.Sleep(1000)

  Catch e As Exception

  End Try

End While

 





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

© 2021 JSCAPE LLC