VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Cisco telnet to devices in .txt file (https://forums.vandyke.com/showthread.php?t=1049)

miwiley 09-26-2005 03:37 PM

Cisco telnet to devices in .txt file
 
Here the script that is interactive today, but I want to have a flat .txt file with devices and specifc commands as well. How can I modify to reflect?

Thanks in advance!
/mike


*******************************

Sub main
' turn on synchronous mode so we don't miss any data
crt.Screen.Synchronous = True

Dim LoggSession

LoggSession = crt.dialog.MessageBox("Do you want to log this session y/n?", "Who is your daddy?", ICON_QUESTION Or BUTTON_YESNO Or DEFBUTTON2 )


' Supply only the prompt text, accept defaults for everything else.

Dim logfile

logfile = crt.Dialog.Prompt("What is the logfile name?")

logfile = (logfile & ".log")

crt.Session.LogFileName = logfile

' Enable logging
'
crt.Session.Log True

Dim result

' Supply only the prompt text, accept defaults for everything else.
'
result = crt.Dialog.Prompt("What Device do you want to Telnet To?")

' Prompt by supplying all of the parameters

crt.Screen.send("telnet " & result & VbCr)
crt.Screen.WaitforString "name: "
crt.Screen.send "username" & VbCr
crt.Screen.WaitForString "assword:"
crt.Screen.send "password" & VbCr
crt.Screen.WaitForString ">"
crt.Screen.send "enable" & VbCr
crt.Screen.WaitForString "assword:"
crt.Screen.send "password" & VbCr
crt.Screen.WaitForString "#"

Dim commands

Do

' Supply only the prompt text, accept defaults for everything else.
'
commands = crt.Dialog.Prompt("What Commands do you want to run?")

' Prompt by supplying all of the parameters

crt.Screen.send(commands & VbCr)
crt.Screen.WaitforString "#"

commands = crt.dialog.MessageBox("Do you want to run more commands y/n?", "Hello!", ICON_QUESTION Or BUTTON_YESNO Or DEFBUTTON2 )

If commands = IDNO Then

' Stop logging and disconnect.
crt.Session.Log False
crt.Screen.send "exit" & VbCr

Exit Sub

End If

loop

End Sub

erltorres 09-29-2005 02:33 AM

Hi,
I think that you want a file .txt with devices information (ip, name, etc) to send telnet to them and when you are loggen in it send commandS.

I use 2 file .txt to do this in a cisco router,
For example:

Dim fs0
Dim fs1
Dim ts0
Dim ts1
Const ForReading = 1
Dim IP
Dim LINEA

Set fs0 = CreateObject("Scripting.FileSystemObject")
Set ts0 = fS0.OpenTextFile("C:\devices.txt", ForReading)


Do While ts0.AtEndOfStream <> True
'****Use the split command if you have mre information in the line than the IP******
IP = ts0.ReadLine
crt.Screen.Send "telnet " & IP & " & VbCr
'****now you can log in the device...***
Set fs1 = CreateObject("Scripting.FileSystemObject")
Set ts1 = fS1.OpenTextFile("C:\comands.txt", ForReading)
Do While ts1.AtEndOfStream <> True
LINEA = ts1.ReadLine
crt.Screen.Send LINEA & VbCr
crt.Screen.WaitforString "#"
Loop
ts1.Close()
Loop
ts0.Close()

Bye.


All times are GMT -6. The time now is 04:03 AM.