Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-26-2005, 03:37 PM
miwiley miwiley is offline
Registered User
 
Join Date: Sep 2005
Posts: 1
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
Reply With Quote
  #2  
Old 09-29-2005, 02:33 AM
erltorres erltorres is offline
Registered User
 
Join Date: Sep 2005
Posts: 4
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.
Reply With Quote
Reply


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 08:37 PM.