Please note, this is a STATIC archive of website www.softperfect.com from 04 Jul 2018, cach3.com does not collect or store any user information, there is no "phishing" involved.

Example of how to use Telnet

Started by Rmpf2

Rmpf2

Example of how to use Telnet   14 April 2017, 03:09

The new Telnet feature sounds interesting. Can you give an example of how can this can be used. Maybe a sample script that shows the proper way to be implemented.

Thanks!
SoftPerfect Support forum - Andrew avatar image

Re: Example of how to use Telnet   14 April 2017, 09:57

Sure. There's a sample actually, though it's only shown when the default config is loaded.

Here's the sample code:
'Retrieve system info via Telnet
'This example code can be adapted to work
'with any device that supports the protocol

'Create internal Telnet object
set objTelnet = Internal.CreateObject("Telnet")

'Set host name and port
objTelnet.Host = Input.Current
objTelnet.Port = 23

'Make connection
objTelnet.Connect

'Wait for login prompt
objTelnet.WaitFor("login:")
'Then send login name
objTelnet.Send("YourUserName" & vbCrLf)

'Wait for password prompt
objTelnet.WaitFor("password:")
'Then send password
objTelnet.Send("YourPassword" & vbCrLf)

'Wait for shell prompt
objTelnet.WaitFor("xsh>")
'Then send command
objTelnet.Send("show sys versions" & vbCrLf)

'Wait for shell prompt (when command finishes)
data = objTelnet.Recv("xsh>")

'Return data and disconnect
Output.Write data
objTelnet.Disconnect

Sometimes you can get the answer faster if you try the forum search and/or have a look at the software user manual to see if your question has already been answered.

Our forum rules are simple:

  • Be polite.
  • Do not spam.
  • If possible, check your spelling and grammar.

Author:

Email:

Subject

A brief and informative title for your message, approximately 4–8 words:

     

Spam prevention: please enter the following code in the input field below.

 **              **        **  **      **  **     ** 
 **              **        **  **  **  **  ***   *** 
 **              **        **  **  **  **  **** **** 
 **              **        **  **  **  **  ** *** ** 
 **        **    **  **    **  **  **  **  **     ** 
 **        **    **  **    **  **  **  **  **     ** 
 ********   ******    ******    ***  ***   **     ** 

Message: