0

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

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Biche_XD
  • 21
  • 2
  • Have you tried piping the output of cat to goaccess? `cat /var/log/apache2/home_access.log | goaccess -a > /tmp/report.html` – Kayla Mar 10 '14 at 02:13
  • This command doesn't display result. – Biche_XD Mar 11 '14 at 09:41
  • 1
    Seems this was fixed in the master [branch](https://github.com/allinurl/goaccess/commit/ba479185e73dc1e14f63c0f14c97de5c51ec5c61). – Kayla Mar 12 '14 at 13:52

0 Answers0