0
hosts=['10.101.x.x'] username='root' password=''
from datetime import datetime date = datetime.now() dates
=date.strftime('%d%b%Y') print dates CheckStr = "Log-" + dates print CheckStr
cmd1='cd /usr/local/element/log/global/log/;ls -ltr' cmd2='/usr/local/element/rel/RAN_RCS_1.0.0.31/bin/linux-x86_pcm64/execCmdCli' cmd3='element add filter rule SPNLOGS enable class SPNAPP severity Informational,Major,Debug,Critical,Minor target log'
def work_comp():
for host in hosts:
print host
ssh = paramiko.SSHClient()
global ssh
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=username, password=password, timeout=5.0)
exe_comm(cmd1)
exe_comm(cmd2)
ssh.close()
# cmd='cd /usr/local/element/log/global/log/;ls -ltr'
# cmd2='pwd'
# #cmd2='/usr/local/element/rel/RAN_RCS_1.0.0.31/bin/linux-x86_pcm64/execCmdCli'
# cmd3='element add filter rule SPNLOGS enable class SPNAPP severity Informational,Major,Debug,Critical,Minor target log'
# #cmd5="date |awk '{print $2,$3,$6}'"
def exe_comm(cmd):
stdin, stdout, stderr = ssh.exec_command(cmd)
for line in stdout:
print (line)
print "Done"
work_comp()