Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-11-2013, 07:23 AM
kurtmanzano kurtmanzano is offline
Registered User
 
Join Date: May 2013
Posts: 6
simple ip textfile loop help

hi i just want to

connect telnet from line 1 of ip.txt
then common commands
disconnect

then connect telnet from line 2 of ip.txt
then common commands
disconnect


and so on and so on can some one help?

this is my code
Code:
#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True
Const ForReading = 1

Sub Main
	' Open a file, read it in & send it one line at a time
	Dim fso, f

	Set fso = CreateObject("Scripting.FileSystemObject")

	Set f = fso.OpenTextFile("d:\ip.txt", ForReading, 1)

	Dim line, params 
	Do While f.AtEndOfStream <> True

		' Read each line of the ip file.
		'
		line = f.Readline
		crt.Session.Connect "/TELNET " & params(0) & " " & 23

		crt.Screen.WaitForString "Password: "
		crt.Screen.Send "password" & chr(13)
		crt.Screen.WaitForString "router> "
		crt.Screen.Send "exit" & chr(13)

		Set objFSO = CreateObject("Scripting.FileSystemObject")


		Const ForWriting = 2
		Const ForAppending = 8

		' Create a new file (or overwrite an existing one)
		Set objStream = objFSO.OpenTextFile( _
					"D:\MyDataFile.txt", _
					ForAppending, _
					True)

		objStream.WriteLine crt.Session.RemoteAddress
		objStream.Close
		crt.Screen.Send "exit" & chr(13)
	loop
End Sub

Last edited by miked; 05-11-2013 at 10:30 AM. Reason: put code in code block
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 07:38 AM.