Solved

Automate switch config backup

Posted on 2016-11-28
3
59 Views
Last Modified: 2016-11-29
I have a list of switches that I want to copy the config from.  I have a script that I can copy the config from one of them.  Can you help me modify this for many switches? They are all the same model.  This script connects via telnet and saves the config to a tftp server.

<job>
<script language="VBScript">
Option Explicit
On Error Resume Next
Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "telnet 172.25.209.254 23"
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys ("^Y")
WScript.Sleep 1000
WshShell.SendKeys ("EN")
WScript.Sleep 1000
WshShell.SendKeys ("{Enter}")
WScript.Sleep 3000
WshShell.SendKeys ("copy running-config tftp address 172.24.109.124 filename Backup2.txt")
WScript.Sleep 1000
WshShell.SendKeys ("{Enter}")
WScript.Sleep 1000
WshShell.SendKeys ("logout")
WScript.Sleep 1000
WshShell.SendKeys ("{Enter}")
WScript.Quit 
</script>
</job>

Open in new window

0
Comment
Question by:Roccat
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 500 total points
ID: 41905259
all I have done is split the telnet code out into a Sub and then called it using different target and backupfiles
you could also consider a telnet app that lets you supply a command file as sendkeys is often unreliable.

Option Explicit

SaveConfig "172.25.209.254" "172.24.109.24" "backup254.txt"

SaveConfig "172.25.209.252" "172.24.109.24" "backup252.txt"


WScript.Quit

Sub SaveConfig(srcIP, destIP, destFile)
	On Error Resume Next
	Dim WshShell
	set WshShell=CreateObject("WScript.Shell")
	WshShell.run "cmd.exe"
	WScript.Sleep 1000
	'WshShell.SendKeys "telnet 172.25.209.254 23"  '---orig
	WshShell.SendKeys "telnet " & srcIP & " 23"
	WshShell.SendKeys ("{Enter}")
	WScript.Sleep 1000
	WshShell.SendKeys ("^Y")
	WScript.Sleep 1000
	WshShell.SendKeys ("EN")
	WScript.Sleep 1000
	WshShell.SendKeys ("{Enter}")
	WScript.Sleep 3000
	''WshShell.SendKeys ("copy running-config tftp address 172.24.109.124 filename Backup2.txt")   '' ---orig
	WshShell.SendKeys ("copy running-config tftp address " & destIP & " filename " & destFile)
	WScript.Sleep 1000
	WshShell.SendKeys ("{Enter}")
	WScript.Sleep 1000
	WshShell.SendKeys ("logout")
	WScript.Sleep 1000
	WshShell.SendKeys ("{Enter}")
End Sub
 

Open in new window

0
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 41905266
0
 

Author Closing Comment

by:Roccat
ID: 41905632
Thank you!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question