Question

i need an example script or bat file where by i want to do the following :>

test the telnet connection and ports to 3 different machines and ports at the same time.

the machine is very locked down, so unable to install putty or any other 3rd party apps or have web access.

I just need the script to telnet to the 1st box and then move to the next.

i have tried the script below but it just stops on the 1st box

<job>
<script language="VBScript">
    Option Explicit
    On Error Resume Next
    Dim WshShell
    set WshShell=CreateObject("WScript.Shell")
    WshShell.run "cmd.exe"
    WScript.Sleep 1000
    WshShell.SendKeys "telnet x.x.x.x 7005"
    WshShell.SendKeys ("{Enter}")
    WshShell.SendKeys "exit"
    WshShell.SendKeys ("{Enter}")
    WshShell.SendKeys "telnet x.x.x.x 8600"
    WshShell.SendKeys ("{Enter}")
    WshShell.SendKeys "exit"
    WshShell.SendKeys ("{Enter}")
    WScript.Quit 
</script>
</job>

hope someone can shed some light on this.

Many thanks

Marzanur

Was it helpful?

Solution 2

WshShell.SendKeys "telnet x.x.x.x 7005"
WshShell.SendKeys "{Enter}"
WshShell.SendKeys "^]"
WshShell.SendKeys "quit{Enter}"

CTRL + ] jumps out of your telnet session and to the terminal console where you can type quit.

OTHER TIPS

There are several issues with this script:

You need to seperatate the

 Telnet *.*.*.* 7005

Commands with

 wscript.sleep 1000

So that the computer has time to connect. Secondly. Telnet opens in a unique command line interface and "exit" is not an accepted by the telnet interface. However, "quit" is used.

So to replace:

 Wshshell.sendkeys "exit"

With

 Wshshell.sendkeys "quit"
 'Wait for close
 Wscript.sleep 500

Telnet commands -> http://technet.microsoft.com/en-us/library/c.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top