Controlling hyperterminal using a VB program

B

Thread Starter

bokBOk

Hello...

Please help me with this... I just need some expert's advice. I have read forums regarding this topic but unfortunately it wasn't sufficient.

How is it possible to communicate to a router, a CISCO router to be specific, using a VB program instead of the hyperterminal?

I'll really wait for your reply...
Thank you for your help.
 
M

Michael Batchelor

If you're using Hyperterminal to communicate over the serial port, then you need to use the serial port control library in your program. This is easier in VB 6.0 than in the new .net framework. But if you're using Hyperterminal to communicate over a TCP/IP link then you can use the MS TCP stack and open a port. More than likely you're talking to the telnet port on the Cisco. If you're determined to do it yourself, then look for a telnet application code base to work from. If it's newer Cicso you might be using ssh, but I doubt it. Regardless, if you're using a TCP port, the stick with Visual Studio 2005 if you can.

Michael
--
Michael R. Batchelor
www.ind-info.com

Industrial Informatics, Inc.
3281 Associate Dr.
N. Charleston, SC 29418

843-329-0342 x111 Voice
843-412-2692 Cell
843-329-0343 FAX
 
CISCO routers are generally proprietary protocols as far as configuration is concerned.

Otherwise; security would be a problem.
 
Well thank you very much, sir, for the information. I'll try to jam over with the telnet application codes...

However, I'll try another attempt to configure a router in GUI environment. This time, I'll make use of the hyperterminal instead. The idea of this might be simplier since I'll make use of a VB program to connect to the hyperterminal and the hyperterminal will do the necessary. As a matter of fact, I've just tried using this:

Dim connect
connect=interaction.shell("...\hypertrm.exe")

Then make use of Sendkeys to relay the commands to the terminal. I'll just hide the terminal from the user's view. What can you say about this idea? Would this be easier and simplier?
 
D
I use Hyperterm to program our T1 router ACL List automagically.

To start, I wrote a text script. Example follows.

password
enable
enablepassword
configure terminal
ip access-list extended default
deny ip 206.71.60.0 0.0.0.255 any log
deny ip 88.196.152.0 0.0.0.255 any log
no permit ip any any
permit ip any any
do write
exit
exit
exit

The script for your router will likely be different, but it is easy to create by capturing or noting the specific text you type during a session.

The second step is to create a vb script 'router.vbs' that will open hyperterm and transmit the text script created in the preceeding procedure.

Set oshell = createobject("Wscript.Shell")
oshell.run"cmd.exe"
wscript.sleep 500
oshell.sendkeys"hypertrm.exe d:\smtplogs\router.ht"+("{Enter}")
wscript.sleep 6000
oshell.sendkeys"%t"
wscript.sleep 500
oshell.sendkeys"t"
wscript.sleep 500
oshell.sendkeys"d:\smtplogs\router.txt"+("{Enter}")
wscript.sleep 12000
oshell.sendkeys" "
wscript.sleep 6000
oshell.sendkeys" "
wscript.sleep 1500
oshell.sendkeys" "
wscript.sleep 1500
oshell.sendkeys" "
oshell.sendkeys"exit"+("{Enter}")
wscript.sleep 1500
oshell.sendkeys"%f"
wscript.sleep 1500
oshell.sendkeys"x"
wscript.sleep 1500
oshell.sendkeys("{Enter}")
wscript.sleep 1500
oshell.sendkeys"exit"+("{Enter}")
set oshell = nothing

The third step is to create a program that updates or creates the router.txt file with the specific commands required. In my case, I have a MS Access database that reads an email server smtp log looking for abuse patterns. when found, the router.txt is created with the offending IP addresses, then executed via a batch file.

This program is crude, but it works 24/7/365.
Good luck.
 
Brilliant! Thanks for this post. It will definitely solve a lot of problems for me.
Ill try this out now!

Thank you!
 
Top