View Single Post
  #1  
Old 04-04-2018, 06:07 AM
yarthur01 yarthur01 is offline
Registered User
 
Join Date: Apr 2018
Posts: 2
VBScript close SecureCRT

I want to execute VBScript in Securecrt and close the Securecrt software after the script is executed. How to write the script?

the script as following

Code:
#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
    Dim aclname
	Dim ipaddress
	aclname = crt.Arguments(0)
	ipaddress = crt.Arguments(1)
	crt.Screen.Send chr(13)
	crt.Screen.WaitForString "<H3C>"
	crt.Screen.Send "system-view" & chr(13)
	crt.Screen.WaitForString "[H3C]"
	crt.Screen.Send "interface Ethernet 1/0/1" & chr(13)
	crt.Screen.WaitForString "[H3C-Ethernet1/0/1]"
	crt.Screen.Send "undo packet-filter inbound ip-group " & aclname & chr(13)
	crt.Screen.WaitForString "[H3C-Ethernet1/0/1]"
	crt.Screen.Send "quit" & chr(13)
	crt.Screen.WaitForString "[H3C]"
	crt.Screen.Send "acl number " & aclname & chr(13)
	crt.Screen.WaitForString "[H3C-acl-adv-" & aclname & "]"
	crt.Screen.Send "rule deny ip source " & ipaddress & " 0" & chr(13)
	crt.Screen.WaitForString "[H3C-acl-adv-" & aclname & "]"
	crt.Screen.Send "rule deny ip destination " & ipaddress & " 0" & chr(13)
	crt.Screen.WaitForString "[H3C-acl-adv-" & aclname & "]"
	crt.Screen.Send "quit" & chr(13)
	crt.Screen.WaitForString "[H3C]"
	crt.Screen.Send "interface Ethernet 1/0/1" & chr(13)
	crt.Screen.WaitForString "[H3C-Ethernet1/0/1]"
	crt.Screen.Send "packet-filter inbound ip-group " & aclname & chr(13)
	crt.Screen.WaitForString "[H3C-Ethernet1/0/1]"
	crt.Screen.Send "quit" & chr(13)
	crt.Screen.WaitForString "[H3C]"
	crt.Screen.Send "quit" & chr(13)
	crt.Screen.WaitForString "<H3C>"
	crt.Session.Disconnect
End Sub

how to close the Securecrt after the script is executed?
Reply With Quote