var port = 22; // any port number
var target = "localhost"; // string Hostname or IP
//checking the connectivity applying try catch and finally
try {
// testing for port connectivity
on target host
System.log("Trying to
connect to port " + port + " on host " + target);
var telnet = new TelnetClient("vt100") ;
//vt100 can be anything like ANSI,
VT52, VT102, VTNT
telnet.connect(target, port);
connectionSuccess =
telnet.isConnected();
System.log("Connectivity " + target + " is successful")
} catch (e) {
connectionSuccess =
telnet.isConnected();
System.log("Connection
failed with error : " + e)
} finally {
telnet.disconnect()
System.log("Disconnecting the connection")
}