A brief description of the script and script for automatic securecrt login to the server

Source: Internet
Author: User

When using SSH to log on to the server with secure, if there are many servers, It is very troublesome to log on to the server at one time. Therefore, you can write VBScript on your own.

I. Introduction to the secure script

Secure is a VBScript, VB Script tutorial, please refer to the relevant documentation.

The built-in secure objects are as follows:

The application object, that is, CRT, is a top-level object. All other content is obtained from this object.

Session, Session object, responsible for connection

Tab object, which is a tab

Scree object, responsible for interaction, such as sending commands, receiving command responses, etc.

Here are some of the above. For other help documents, see.


Ii. Description of Automatic Login

1. Create a session and connect to the server

There are two methods, one is to set the parameter connection, the other is to use the existing session settings to connect


Method 1:

CRT. session. Connect ("protocol user @ host ")

Protocol: Protocol, supporting SSH, SSH2, and telnet

User: User Name

HOST: Machine name

Method 2:

Set conf = CRT. opensessionconfiguration ("session_name ")

Set Tab = Conf. connectintab ()


Session_name: the name of the session you set. The advantage of this is that you can use the set session to connect to the session, which is simple.


2. Clone the tab and log on to the server.

Set newtab = tab. Clone ()

The advantage of cloning is that you do not need to log on again and simply clone existing ones.


3. Set the tab name.

Tab. Caption = xxx

When there are more tags, you need to set an alias for each one.


4. Connect to the server

The connection function mainly involves various methods in the screen object.

Set scr = tab. Screen 'first obtains the screen of the tab.

SCR. Send ("ssh" & host & vbcr) 'sends the SSH logon command

SCR. waitforstring (host & "'s password:") 'waiting for the password prompt

SCR. Send (PWD & vbcr) 'enter the password


Iii. Complete example

# $ Language = "VBScript" <br/> # $ interface = "1.0" <br/> CRT. screen. synchronous = true <br/> function login (PTAB, name, host, PWD, CMD) <br/> dim tab, SCR <br/> Set Tab = PTAB. clone () <br/> tab. caption = Name <br/> set scr = tab. screen <br/> SCR. send ("ssh" & host & vbcr) <br/> SCR. waitforstring (host & "'s password:") <br/> SCR. send (PWD & vbcr) <br/> SCR. send (CMD & vbcr) <br/> set login = tab <br/> end function <br/> sub main <br/> dim Conf, tab <br/> set conf = CRT. opensessionconfiguration ("session_name") <br/> Set Tab = Conf. connectintab () <br/> Set Tab = login (tab, "name1", "user1 @ host1", "XXX", "CD/home /") <br/> Set Tab = login (tab, "name2", "user2 @ host2", "XXX", "shell cmd") <br/> end sub 


For more information, see the Help File of securecrt.

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.