Solved

Automate switch config backup

Posted on 2016-11-28
3
80 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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