SecureCRTScript learning notes

Source: Internet
Author: User
SecureCRT supports ActiveXscriptengines, including VBScript and JScript (Microsoft & amp; rsquo; sversionofJavaScript. Note: If you want to use the automatic script running mode, you need to set it in sessionoption. The script can be...

SecureCRT supports ActiveX script engines, including VBScript and JScript (Microsoft's version of JavaScript.

Note: If you want to run the script automatically, you need to set it in session option.

The script can be developed using any text editor. The Script header is used to identify the version of the Script language and SecureCRT Script interface. Each line in the Script header must start with #. the header includes the $ language Line and $ interface line. For example, the following is a simple script.
# $ Language = "VBScript"
# $ Interface = "1.0"

Sub Main
'Display SecureCRT's version
MsgBox "SecureCRT version is:" & crt. Version
End Sub
Code is usually placed in the main sub-process. Before the engine executes the main sub-process, it converts and executes Global Code (the script code is defined outside any sub-process). If you have some initialization processing, this feature can be used.

If you want to terminate the main process and use VBScript, you can use the Exit Sub statement. For example:
Sub Main

Condition = DoSomething ()
If condition = 0 Then
'Error, comment lout
Exit Sub
End If

End Sub
SecureCRT has some built-in objects that can be called through top-level application objects or sub-objects. These objects have some attributes and methods. For example:
Dim dlg
Set dlg = crt. Dialog
Dlg. Prompt ("Login :")


The following is a script:
[Javascript]
# $ Language = "VBScript"
# $ Interface = "1.0"
 
Sub Main
Dim Counter
 
Crt. Screen. Send "setenv loadaddr 800000" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "setenv fdtaddr 780000" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "setenv bootfile uImage" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "setenv fdtfile mpc8349emitx. dtb" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "setenv serverip 10.1.0.77" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "setenv rootpath/home/test/nfs/rootfs" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "setenv ipaddr 10.1.0.100" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. screen. send "setenv bootargs root =/dev/nfs mem = 1024 M rw nfsroot = $ serverip: $ rootpath ip = $ ipaddr: $ serverip: $ gatewayip: $ netmask: $ hostname: $ netdev: off console = $ console, $ baudrate $ otherbootargs "& vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "setenv nfsboot 'tftp $ fdtaddr $ fdtfile \; tftp $ loadaddr $ bootfile \; bootm $ loadaddr-$ fdtaddr '" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "setenv bootcmd $ nfsboot" & vbCr
Crt. Screen. WaitForString "HD-Mother>"
Crt. Screen. Send "boot" & vbCr
 
Author: tchonggang77

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.