Telnet to Scounix and get the result

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.