If i'm here, it's for a problem than i can't to solve alone.
I'm trying to do a code who do ssh connection to a server and send me a mail with Apache stats (generate by GoAccess).
Here is my code :
#!/usr/bin/env python2
import paramiko
cmd2 = "goaccess -f /var/log/apache2/home_access.log -a > /tmp/report.html"
def ssh_connect(host, login, password):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username = login, password = password)
stdin, stdout, stderr = \
ssh.exec_command(cmd2)
return stdout.readlines()
print cmd2
print ssh_connect('MyServer', 'MyUsername', 'MyPassword')
This is the result :
root@raspberrypi:/tmp# ./webstat.py goaccess -f /var/log/apache2/home_access.log -a > /tmp/report.html
I confirm that the above command works on my server in local (the result is a HTML code generate in report.html)
But, when this command is passed by paramiko, i've the man page of GoAccess in report.html.
I think than my cmd2 var is not correct but I don't know why (special character?)
Do you have an idea ?
Thanks for help