下面是script部分
一,服务端
#!/usr/bin/Python
# -*- coding:utf-8 -*-
#Version:1.0.0
#Author:liyinda
from socket import *
import os,sys
CliHost = sys.argv[1]
CliPort = 5555
Input = raw_input("input:")
Message = str(Input)
try:
Sock = socket(AF_INET,SOCK_STREAM)
Sock.connect((CliHost,CliPort))
Sock.send(Message)
Data = Sock.recv(1024)
print '==>',Data
Sock.close()
except Exception:
print '无法更改系统时间!'
二,客户端
#!/usr/bin/python
# -*- coding:utf-8 -*-
#Version:1.0.0
#Author:liyinda
from socket import *
import os
MyHost = ''
MyPort = 5555
SockObj = socket(AF_INET,SOCK_STREAM)
SockObj.bind((MyHost,MyPort))
SockObj.listen(True)
while True:
connection,address = SockObj.accept()
print '===>',address[0]
CMD = connection.recv(1024)
print CMD
if str(CMD).find('date',0,4) == 0:
os.system(str(CMD))
SendCMD = os.popen(str(CMD)).read()
connection.sendall(str(SendCMD))
connection.close()
else:
connection.sendall('请更改系统时间!')