http://blog.csdn.net/marising/article/details/6409196
Secure with SSH login server, if the server is more, landing once very troublesome, so, you can write VBScript to do it.
First, secure script introduction
Secure is a tutorial for VBScript scripts, VB scripts, please refer to the documentation.
Secure comes with the following objects:
The Application object, which is the CRT, is a top-level object, and all other content is derived from this object.
Session, conversation object, responsible for connection related
Tab object, which is the tab page
Scree object, which is responsible for interactive correlation, such as sending commands, receiving command returns, etc.
The main ones are the above, others look at the help document.
Second, the automatic landing instructions
1. Create session and connect to server
There are two ways, one is to set the parameter connection, one is to use the existing session settings to connect
Mode 1:
Crt.session.Connect ("protocol [email protected]")
Protocol: protocol, support Ssh,ssh2,telnet
User: Username
Host: Machine name
Mode 2:
Set conf = crt. Opensessionconfiguration ("Session_name")
Set tab = Conf. Connectintab ()
Session_name: It is the name of the session you set yourself, so the advantage is that you can use the set session to connect and simply.
2. Clone tab and login to server
Set newtab = tab. Clone ()
The advantage of cloning is no longer landing, directly clone already have.
3. Set the name of the tab, etc.
tab. Caption = xxx
More labels, one alias per setting required
4. Connect to the server
The connection function is mainly a variety of methods in the Screen object.
Set SCR = tab. Screen ' first gets tab screen
Scr. Send SSH Login command ("SSH" & Host & vbcr)
Scr. Waitforstring (host & ' s password: ") ' Prompt for password
Scr. Send (pwd & vbcr) ' Enter password
Third, complete examples
[VB]View Plaincopy
- # $language = "VBScript"
- # $interface = "1.0"
- Crt. screen.synchronous = True
- Function Login (Ptab,name,host,pwd,cmd)
- Dim TAB,SCR
- Set tab = Ptab. Clone ()
- tab. Caption = Name
- Set SCR = tab. screen
- Scr. Send ("SSH" & host & vbcr)
- Scr. Waitforstring (Host & "' s Password:")
- Scr. Send (pwd & vbcr)
- Scr. Send (cmd & vbcr)
- Set Login = Tab
- End Function
- Sub Main
- Dim Conf,tab
- Set conf = crt. Opensessionconfiguration ("Session_name")
- Set tab = Conf. Connectintab ()
- Set tab = Login (tab,"name1","[email protected]", "xxx","cd/home/")
- Set tab = Login (tab,"Name2","[email protected]", "xxx","shell cmd")
- End Sub
For a more detailed introduction, please refer to the SECURECRT Help file.
SECURECRT Automatic Login to server script and scripting simple instructions