Getting a task response

Top  Previous  Next

Under certain conditions you may want to see the data received from the telnet server while the task was executing. To get this data invoke the TelnetTask.GetResponse 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.GetResponse.IndexOf("Success") != -1) {

 Console.WriteLine("Successful");

}

// 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()

 

If (sh_exec.GetResponse().IndexOf("Success") <> -1) Then

  ' success - logout

   myTelnet.Disconnect()

End If





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

© 2021 JSCAPE LLC