sms_shelll
来源:互联网 发布:excel怎么复制所有数据 编辑:程序博客网 时间:2024/06/08 14:41
# -*- coding: UTF-8 -*-
__author__ = 'EX-PENGFEI913'
import time,paramiko,re,StringIO,unicodedata
def exec_shell(command):
f = StringIO.StringIO()
header_match = '(\[.+?@.+?\s.+?\]\$)'
ssh.send(command+'\n')
while True:
out = ssh.recv(1024)
print out,
f.write(out)
header_list = re.findall(header_match, out)
if header_list and out.strip().endswith(header_list[-1]):
break
return f
def check_ip(content):
ips = re.findall('\d+\.120\.\d+\.\d+',content)
return ips
if __name__ == '__main__':
host = '10.59.72.161'
port = 22
username = 'www'
password = '2V4B6cw9B0'
s = paramiko.SSHClient()
s.load_system_host_keys()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect(host, port, username, password)
ssh = s.invoke_shell()
a=exec_shell('ps aux|grep send_message')
#b=exec_shell('ps aux|grep send_result')
stdin, stdout, stderr = s.exec_command('ps aux|grep send_message')
#stdin, stdout, stderr = s.exec_command('ps aux|grep send_result')
c=stdout.readlines()[1]
#c=stdout.readlines()[1]
files = unicodedata.normalize('NFKD', c).encode('utf-8', 'ignore')
print type(files)
files = files.split(' ')
files_List = []
for i in range(len(files)):
files_List.append(files[i])
print files_List[6]
command='kill '+' '+ files_List[6]
print command
exec_shell(command)
exec_shell('ps aux|grep send_message')
#exec_shell('ps aux|grep send_result')
#ips = check_ip(s.getvalue())
#exec_shell('cat '+ips[0]+'/log/duobao.log')
__author__ = 'EX-PENGFEI913'
import time,paramiko,re,StringIO,unicodedata
def exec_shell(command):
f = StringIO.StringIO()
header_match = '(\[.+?@.+?\s.+?\]\$)'
ssh.send(command+'\n')
while True:
out = ssh.recv(1024)
print out,
f.write(out)
header_list = re.findall(header_match, out)
if header_list and out.strip().endswith(header_list[-1]):
break
return f
def check_ip(content):
ips = re.findall('\d+\.120\.\d+\.\d+',content)
return ips
if __name__ == '__main__':
host = '10.59.72.161'
port = 22
username = 'www'
password = '2V4B6cw9B0'
s = paramiko.SSHClient()
s.load_system_host_keys()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect(host, port, username, password)
ssh = s.invoke_shell()
a=exec_shell('ps aux|grep send_message')
#b=exec_shell('ps aux|grep send_result')
stdin, stdout, stderr = s.exec_command('ps aux|grep send_message')
#stdin, stdout, stderr = s.exec_command('ps aux|grep send_result')
c=stdout.readlines()[1]
#c=stdout.readlines()[1]
files = unicodedata.normalize('NFKD', c).encode('utf-8', 'ignore')
print type(files)
files = files.split(' ')
files_List = []
for i in range(len(files)):
files_List.append(files[i])
print files_List[6]
command='kill '+' '+ files_List[6]
print command
exec_shell(command)
exec_shell('ps aux|grep send_message')
#exec_shell('ps aux|grep send_result')
#ips = check_ip(s.getvalue())
#exec_shell('cat '+ips[0]+'/log/duobao.log')