Batch backup of network device scripts with VBS scripts via SECURECRT Telnet
Use: Open SecureCRT and select script to run this script to
This script calls the e:/device backup/ip.txt file in this file format: IP address user name password device name
# $language = "VBScript" # $interface = "1.0" CRT. screen.synchronous = truesub mainconst forreading = 1forwriting = 2forappending = 8dim wordkeydim fsodim file1dim linedim paramsset fso = createobject ("Scripting.FileSystemObject") Set file1=fso. OpenTextFile ("E:\ device backup \ip.txt", forreading,false) ' file format:ip user name password device name While file1. Atendofstream <> true ' reads the file line = file1 by line. readlineparams = split (line) CRT. session.connect "/telnet" & " " & params (0) ' equivalent &NBSP;TELNET&NBSP;IP address 23crt. session.logfilename = "e:/device backup/" + params (3) + replace (replace (replace (date, ":", ""), "/", ""), " ", ") + " _log.txt "CRT. Session.log truewordkey = crt. screen.waitforstrings ("Username:", "Login:", "Username:", 3) &NBSP;&NBSP; ' Select select case wordkeycase 1crt in 3 seconds based on the login prompt. Screen.send params (1) &NBSP;&&NBSP;CHR (CRT). screen.waitforstring "passcode:" CRT. Screen.send params (2) &NBSP;&&NBSP;CHR (CRT). screen.waitforstring "#" CRT. screen.send "Show run" &NBSP;&&NBSP;CHR (while ) (Crt. Screen.waitforstring ("--more--", 3) = true) CRT. screen.send " " WENDCASE&NBSP;2CRT. Screen.send params (1) &NBSP;&&NBSP;CHR (CRT). screen.waitforstring "password: " CRT. Screen.send params (2) &NBSP;&&NBSP;CHR (CRT). screen.waitforstring ">" CRT. screen.send "Dis cu" &NBSP;&&NBSP;CHR (while ) (Crt. Screen.waitforstring ("---- More ----", 3) = true) CRT. screen.send " " &NBSP;WENDCASE&NBSP;3CRT. Screen.send params (1) &NBSP;&&NBSP;CHR (CRT). screen.waitforstring "Password:" CRT. Screen.send params (2) &NBSP;&&NBSP;CHR (CRT). screen.waitforstring ">" CRT. screen.send "DIS&NBsp;cu "&NBSP;&&NBSP;CHR (while ) (Crt. Screen.waitforstring ("---- More ----", 3) = true) CRT. screen.send " " wendend selectcrt.session.disconnectwendcrt.screen.synchronous = Falseend sub
CRT bulk Backup Network device script