Article title: Telnet to Scounix for execution and obtain the result. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
A monitoring program was run in the previous section. after the event is triggered, telnet to Sco unix to execute the command and obtain the command result. after a few days, I finally finished it. I would like to share with you:
1. install the TelnetTool control (for download)
II. VFP code:
LOCAL telnet1 Telnet1 = CREATEOBJECT ("Dart. Telnet.1 ") Telnet1.Timeout = 100 Telnet1.TermType = "vt100" False =. t. True =. t.
VbCrLf = CHR (13) + CHR (10) ** Logfile = "Host" + HostIP + ". log" ** Telnet1.Trace (logfile, False, True, vbCrLf + "--->", vbCrLf + "<---")
Thisform. AddLog (Tsys_kind, "connecting host" + HostIP + "..." + vbCrLf)
OK = Telnet1.Connect (HostIP, 23) IF OK = "" Thisform. AddLog (Tsys_kind, "UnionPay front [" + HostIP + "] connection failed! The link with the UnionPay center cannot be checked. ") Thisform. showinfo ("99", "Error: UnionPay frontend connection failed! ") Thisform. warn Thisform. command4.Picture = "deng3.gif" Thisform. command4.refresh Telnet1.close RETURN ELSE Telnet1.close Telnet1.Timeout = 10000 Telnet1.Connect (HostIP, 23) ENDIF Thisform. AddLog (Tsys_kind, "connected" + vbCrLf)Data = "" Telnet1.Search (@ Data, "login :") * Thisform. AddLog (Tsys_kind, Data) Telnet1.Send (User_name + vbCrLf) Data = "" Telnet1.Search (@ Data, "Password :") * Thisform. AddLog (Tsys_kind, Data) Telnet1.Send (User_pwd + vbCrLf) Data = "" Telnet1.Search (@ Data, "> ") * Thisform. AddLog (Tsys_kind, Data) Telnet1.Send ("su" + vbCrLf) Telnet1.Search (@ Data, "Password :") * Thisform. AddLog (Tsys_kind, data) Telnet1.Send (root_pwd + vbCrLf) Telnet1.Search (@ Data ,"#") * Thisform. AddLog (Tsys_kind, Data) Telnet1.Send (shell_cmd + vbCrLf) Telnet1.Search (@ Data ,"#") * Thisform. AddLog (Tsys_kind, data) |
* ***************
OK = VAL (STREXTRACT (data, "/", "/", 3 ))
IF OK> WP04 & Warn Point
Thisform. showinfo ("01 ","★Warning UnionPay center network latency [9.234.12.21]! Current value: "+ ALLTRIM (STR (OK, 10, 2) +" set value: "+ ALLTRIM (STR (WP04, 10, 2 )))
Thisform. addlog (Tsys_kind ,"★Warning UnionPay center network latency [9.234.12.21]! Current value: "+ ALLTRIM (STR (OK, 10, 2) +" set value: "+ ALLTRIM (STR (WP04, 10, 2 )))
...... & Trigger event
ENDIF