Earlier I have written a post Expect-Automating Command line tools for Expect utility. Now we can access any server machines by using VBScript. Dimac Development has implemented a COM interface to connect through Telnet and made as freeware. You need to download w3Sockets Dll and register it using SocketReg.exe included in a zip file. It is similar to expect utility. You can verify each command and can change the execution flow based on console output. It is much useful for automated testing as well as server administration. Below I have given a sample code to start windows services.
w3Sockets Reference
w3Sockets - Download Page
To start servers on Windows/Unix/Linux Systems
'To start servers on Windows/Unix/Linux server
Dim w3sock
Set w3sock = CreateObject("socket.tcp")
With w3sock
.timeout = 5000
.DoTelnetEmulation = True
.TelnetEmulation = "TTY"
.Host = "myserver:23"
.Open
.WaitFor "login:"
WScript.Echo .Buffer
.SendLine "myloginid"
.WaitFor "password:"
.SendLine "Password12"
.WaitFor ">"
.SendLine "net start ""MyServer Manager"""
.WaitFor ">"
WScript.Echo .Buffer
.SendLine "net start ""MYDB Repository"""
.WaitFor ">"
WScript.Echo .Buffer
.Close
End With
Set w3sock = Nothing
No comments:
Post a Comment