Use the securecrt Script Function to easily manage several examples-create a chmod chown script to help you

Source: Internet
Author: User
Http://www.justwinit.cn/post/2295/

Every time you go to chmod-R *; chown-r nobody. nogroup * is very troublesome. Write a script to solve it. Then you can directly call the securecrt script -- run -- select the script!
CodeAs follows:

Sub main
CRT. Screen. synchronous = true
CRT. Screen. Send "chmod-r 755 *" & vbcr
CRT. Screen. Send "chown-r nobody. nogroup *" & vbcr
CRT. Screen. Send ""
CRT. Screen. synchronous = false
End sub

[Preface]
Securecrt is a popular and popular remote logon and terminal simulation software that supports Telnet and SSH.
It also supports VBScript and JScript. With script support, securecrt can automatically complete our settings.
Various tasks.
[Example 1]
# $ Language = "VBScript"
# $ Interface = "1.0"
'Script example: Automatically log on to a 3550 switch device, automatically enter the remote logon password, and automatically enter the privileged mode.
'Automatically enter the privileged password and run the show version command.

Sub main
CRT. Screen. synchronous = true
'Connect to 192.168.1.1 through Telnet
CRT. session. Connect "/telnet 192.168.1.1"
CRT. Screen. waitforstring "Password :"
CRT. Screen. Send "Cisco" & vbcr
CRT. Screen. waitforstring ">"
CRT. Screen. Send "enable" & vbcr
CRT. Screen. waitforstring "Password :"
CRT. Screen. Send "Cisco" & vbcr
CRT. Screen. waitforstring "#"
CRT. Screen. Send "show version" & vbcr
CRT. Screen. waitforstring "-- more --"
CRT. Screen. Send ""
CRT. Screen. synchronous = false
End sub

[Example 2]
# $ Language = "VBScript"
# $ Interface = "1.0"
'The script example: automatically reads the IP address and password of the device from a file, and automatically backs up the Device Configuration

Sub main
'Open the file that saves the device management address and password.
Const forreading = 1, forwriting = 2, forappending = 8
Dim FSO, file1, line, str1, Params
Set FSO = Createobject ("scripting. FileSystemObject ")
Set file1 = FSO. opentextfile ("D: \ config.txt", forreading, false)
CRT. Screen. synchronous = true
Do While file1.atendofstream <> true
'Read each line
Line = file1.readline
'Separate the parameter IP address and password of each line
Params = Split (line)
'Telnet to this device
CRT. session. Connect "/telnet" & Params (0)
'Enter the Telnet password.
CRT. Screen. waitforstring "Password :"
CRT. Screen. Send Params (1) & vbcr
'Enter the privileged Mode
CRT. Screen. Send "enable" & vbcr
CRT. Screen. waitforstring "Password :"
CRT. Screen. Send Params (2) & vbcr
CRT. Screen. waitforstring "#"
'Backup the current STARTUP configuration
Str1 = "Copy startup TFTP: // 192.168.1.2 /"
Str1 = str1 & "backup (" & Params (0) & ")" & ". cfg"
CRT. Screen. Send str1 & vbcr
CRT. Screen. waitforstring "]? "
CRT. Screen. Send vbcr
CRT. Screen. waitforstring "]? "
CRT. Screen. Send vbcr
'Exit after the backup is complete
CRT. Screen. waitforstring "#", 3
CRT. session. Disconnect
Loop
CRT. Screen. synchronous = false
End sub

The config.txt text file is pre-edited
Format:
192.168.1.1 Cisco
192.168.1.254 Cisco
The front is the IP address, the back is the Telnet password, and the last is the Enable Password

Sub main
'Open the file that saves the device management address and password.
Const forreading = 1, forwriting = 2, forappending = 8
Dim FSO, file1, line, str1, Params
Set FSO = Createobject ("scripting. FileSystemObject ")
Set file1 = FSO. opentextfile ("D: \ config.txt", forreading, false)
CRT. Screen. synchronous = true
Do While file1.atendofstream <> true
'Read each line
Line = file1.readline
'Separate the parameter IP address and password of each line
Params = Split (line)
'Telnet to this device
CRT. session. Connect "/telnet" & Params (0)
'Enter the Telnet password.
CRT. Screen. waitforstring "Password :"
CRT. Screen. Send Params (1) & vbcr
'Enter the privileged Mode
CRT. Screen. Send "enable" & vbcr
CRT. Screen. waitforstring "Password :"
CRT. Screen. Send Params (2) & vbcr
CRT. Screen. waitforstring "#"
'Backup the current STARTUP configuration
Str1 = "Copy startup TFTP: // 192.168.1.2 /"
Str1 = str1 & "backup (" & Params (0) & ")" & ". cfg"
CRT. Screen. Send str1 & vbcr
CRT. Screen. waitforstring "]? "
CRT. Screen. Send vbcr
CRT. Screen. waitforstring "]? "
CRT. Screen. Send vbcr
'Exit after the backup is complete
CRT. Screen. waitforstring "#", 3
CRT. session. Disconnect
Loop
CRT. Screen. synchronous = false
End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.