# -*- 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('cd /data1/www/paf_release/sms-backend-service/public')
exec_shell('ls')
exec_shell('chmod -Rf +x *')
exec_shell('/data1/env/php-fpm/bin/php pm.phar --start --app=sms_result.php --pidfile=sms_result.pid --daemonize -n 1')
exec_shell('/data1/env/php-fpm/bin/php pm.phar --start --app=send_message.php --pidfile=send_message.pid --daemonize -n 1')
exec_shell('ps aux|grep sms_result')
exec_shell('ps aux|grep send_message')
__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('cd /data1/www/paf_release/sms-backend-service/public')
exec_shell('ls')
exec_shell('chmod -Rf +x *')
exec_shell('/data1/env/php-fpm/bin/php pm.phar --start --app=sms_result.php --pidfile=sms_result.pid --daemonize -n 1')
exec_shell('/data1/env/php-fpm/bin/php pm.phar --start --app=send_message.php --pidfile=send_message.pid --daemonize -n 1')
exec_shell('ps aux|grep sms_result')
exec_shell('ps aux|grep send_message')