回复 4# xms77
代码的作用是telnet到SMbridge 623端口,通过BMC重启服务器
目前只写了前面一部分,后面是输入用户名、密码连接到指定服务器的BMC后执行重启操作
Local $SMBridge_host = "192.168.1.1"
Local $port = 623
Local $SMBridge_username = "administrator"
Local $SMBridge_passwd = "qwerty."
Local $delay = "3000"
TCPStartup()
$socket = TCPConnect($SMBridge_host, $port)
If $socket = -1 Then
MsgBox(48,"Error","无法连接到SMBridge服务器失败,程序将退出!")
TCPCloseSocket($socket)
TCPShutdown()
Exit
EndIf
Sleep($delay)
$ack = BinaryToString(TCPRecv($socket,100,0))
MsgBox(0,"info",$ack) ;显示回显信息,这里则返回乱码,正常应显示Username:
If StringInStr($ack,"0xFFFD18FFFB01FFFE01FFFB03FFFB00FFFD00",1)=0 Then
MsgBox(48,"Error","连接到SMBridge服务器时登陆失败,程序将退出!")
TCPCloseSocket($socket)
TCPShutdown()
Exit
EndIf
|