Automation TELNET commands using VB Script - Saigontech Forum
Thursday, 2016-12-08, 3:48 PM
Welcome Guest | RSS


[ New messages · Members · Forum rules · Search · RSS ]
Page 1 of 11
Saigontech Forum » AAS IT House » Computer Systems Networking and Telecommunications » Automation TELNET commands using VB Script
Automation TELNET commands using VB Script
weoDate: Sunday, 2012-01-15, 11:33 AM | Message # 1
Group: Moderators
Messages: 151
Reputation: 0
Status: Offline
Network Administration - The process by batch job file. Bat (batch job) and more recently using Windows scripts (. WSF) is the leading choice of the network administrator, to increase productivity the most optimal way. Using the batch job you can automatically install and uninstall applications, inventory software or operating system settings for your entire computer network. But there are certain tasks that sometimes require authentication through multiple layers, such as TELNET.
TELNET (short for Network Terminal) is a network protocol (network protocol) is used on the Internet or connect to the connection at the local computer network LAN. The purpose of the TELNET protocol is to provide a general media, with the stream, using the width of 8 bit, byte-oriented.
Many network administrators use TELNET to switch to query or set of ports, monitor the status of system operation, even reboot network devices via the TELNET command line. So will a lot more convenient if you can automate tasks like batch jobs TELNET.
In fact, if you are familiar with using VB script to create Windows scripts, VB script provides a very useful feature when you set up Windows Shell script for the object, then release the object carefully time to time by the command. Basically, it's like you're sitting at a command prompt and type in it. The only difference is the Windows command prompt script will send to you.
TELNET Job Automation

Basically we have two parts to make this task. You need to sequence through statements like the typical TELNET session.
In this example, we have 5 devices on the network to boot remotely via TELNET by using four simple commands. The first is the IP address and use a specific port. Next a menu appears, press Enter.

Choose a number that corresponds to the function at the MAIN MENU, press Enter.

Now we have different methods to do this. Some people prefer to use TST script. But it is somewhat complicated for the novice. TCL is a scripting language like, is used for many years. But here we will guide you to use a VB script file to perform the task in the shortest time, the most simple.
To do this, put all of the following code into a file, such AutoTELNET.wsf, and then double click to run:
First, set TELNET:
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell = CreateObject ("WScript.Shell")
WshShell.Run "cmd.exe"
WScript.Sleep 1000
'Send commands to the window as needed - IP and commands need to be customized
'Step 1 - telnet to remote IP'
WshShell.SendKeys "telnet xx.xx.xx.73 9999"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
The code above will automatically open a command window, then TELNET to the specific device on a port to connect. Replace "x" by your IP.
Sleep command will allow enough time to wait until the device is responsive and prompt script for the next command. So make sure you set time long enough for this operation takes place.
Monday, you need to send commands one at a time. Please provide sufficient time for the meeting between the TELNET session.
'Step 2 - Issue Commands with pauses'
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys "5"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
Finally do not forget to close the command window and end script.
'Step 3 - Exit Command Window
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
</ Script>
</ Job>
That's the whole process automated TELNET, just three easy steps in a script not complicated. After familiarization, you can customize them according to their needs in the automation of management tasks to network switches, time clock or control the system remotely via TELNET.
Saigontech Forum » AAS IT House » Computer Systems Networking and Telecommunications » Automation TELNET commands using VB Script
Page 1 of 11

Note: You take all responsibilities for your talk, post, Saigontechforum. Think Before You Speak