The script could look something like this. I created a file called c:serverslist.txt that contains a lis of servers you'd want to affect. This script reads through the list, connects to the server and issues a shutdown command. Your script may vary, depending on the connection type, login sequence, etc... But you should get an idea from here how it could be done.
This code can be implemented as an on-demand script using the key-mapping feature. The keyword VBSCRIPT at the beginning tells the key mapper to execute the following text as a script when the given key is pressed. Key mapping functionality can be found on the Options->Properties->VTOPtions page.
Code: |
VBSCRIPT
DIM objFSO, objFile, serverName, portNumber, userName, password, retval, timeout
sub MAIN
Print "running"+vbNewLine
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile("c:serverslist.txt",1)
Do until objFile.AtEndOfStream
serverName = objFile.ReadLine
portNumber = objFile.ReadLine
userName = objFile.ReadLine
password = objFile.ReadLine
timeout = objFile.Readline
Print "Shutting down: " + serverName + vbNewLine
Terminal.SetConnectionType "ssh2"
Terminal.SetConnectionHost serverName
Terminal.SetConnectionPort portNumber
Terminal.SetSSHUsername userName
Terminal.SetSSHPassword password
retval = Terminal.Connect ( timeout )
if(retval) then
Terminal.WaitForTimeout "~$", 10000
Terminal.Print("Connected")
Terminal.SendText "sudo shutdown -r now" +vbNewLine
Terminal.WaitForTimeout "password", 10000
Terminal.SendText password+vbNewLine
Terminal.WaitForTimeout "The system is going down"
Terminal.Disconnect
else
Terminal.Print("Not Connected")
end if
Loop
objFile.Close
Print "done"+vbNewLine
end sub
|