View Single Post
Old 01-21-2007, 02:28 AM
wirelessmonk01 wirelessmonk01 is offline
Registered User
Join Date: Nov 2006
Posts: 16
Hey all, I'm still struggling with this script a bit. I decided to work with a different script that was originally intended for changing router passwords. I took out some parts that didn't apply to my situation (i.e. the original offered a telnet, ssh1 or ssh2 case statement, while I only need telnet), and it certainly isn't finished, but I'm running into a bit of a speedbump. We don't log directly on the the remote routers, but rather to a local *nix box that is on a vpn with the routers. The connection with this *nix box is saved as a "session" in Secure CRT. I would like to be able to load this "session" manually, and then run the script rather than write the connection to the *nix box into the script. When I load the "session" and then run the script I get an "already connected" error (specificaly at line 41). I assume this is because SecureCRT already sees a connection open, but how do I get past this? Here's the script so far (*note, I censored some of the info*)

I'm sure I've butchered some stuff in here, but be kind...

#$language = "VBScript"
#$interface = "1.0"

Sub Main
	Const username = "xxxxxx" ' Username to use for login
	Const password = "xxxxxxxx" ' Password for corresponding user
	Const loginPass = "xxxxxxxx" ' Password to use for password only login (aka no aaa new-model)
	Const DEVICE_FILE_PATH = "C:\Documents and Settings\xxxxx\Desktop\devicestest.txt"
	Dim fso
	Set fso = CreateObject("Scripting.FileSystemObject")
	Dim fil
	Set fil = fso.OpenTextFile(DEVICE_FILE_PATH)

	crt.session.Connect("/s xxxxxxxxxx")
	Dim ip
	Dim name
	Dim line
	Dim cnxnString
	While Not fil.AtEndOfStream
		line = fil.ReadLine
		name = Split(line, ",")(0)
		ip = Split(line, ",")(1)
		cnxnString = ("/TELNET " & ip & " 23")
		' Connect 
		crt.Screen.Synchronous = True
		crt.Session.Connect cnxnString
		' Enable
		crt.Screen.WaitForString "Username:"
		crt.Screen.Send username & vbCr
		crt.Screen.WaitForString "Password"
		crt.Screen.Send password & vbCr
End Sub

Ok, I edited this post a bit. I can now start my session within the script, but I'm still getting the same error. "Already connected". Any ideas?

Last edited by wirelessmonk01; 01-21-2007 at 03:27 AM.
Reply With Quote