|
#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
Greetings kurtmanzano,
I don't see any obvious problems with the code. What happens when you run it? If you'd like to show any screen output please send the data to support@vandyke.com, with subject line of Forum 11019.
__________________
Mike VanDyke Software Technical Support [http://www.vandyke.com/support] |
#3
|
|||
|
|||
working but have question
got this working
with this code #$language = "VBScript" #$interface = "1.0" Sub Main On Error Resume Next ' Open the hosts file Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set fileHosts = fso.OpenTextFile("d:\ip.txt", 1) szHost = fileHosts.ReadLine Do While len(szHost) > 4 crt.session.connect("/telnet " & szHost) crt.Screen.Synchronous = True crt.Screen.Send VbCr ' Commands crt.Screen.WaitForString "Password:" crt.Screen.Send "password1234" & chr(13) crt.Screen.WaitForString "router> " ' START WRITING FILE Set objFSO = CreateObject("Scripting.FileSystemObject") 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 ' END WRITING FILE ' Commands crt.Screen.Send "exit" & chr(13) szHost = fileHosts.ReadLine Loop End Sub But i have a question is it possible since i connect from an ip list file (ip.txt) to make this multi threaded like run 1st five ips from the text file, then next five from text file? > running on tabs thanks |
#4
|
||||
|
||||
There is no multithreaded capability with the SecureCRT scripting API. You could workaround this if you use one script to read the IP list and start SecureCRT with command-line arguments, including the hostname or IP to connect to, /T to open in a tab, and the script to run. If you wanted to limit the number of simultaneous open connections to like five, the calling script would need to manage the connections. This would be a complicated solution.
I've added your forum post to our request database so that we can follow up in this thread if it becomes possible in a future release. Let us know and refer to forum thread 11019 if you'd like to be notified via e-mail as well.
__________________
Mike VanDyke Software Technical Support [http://www.vandyke.com/support] |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|