2

I've been pulling my hair with this script:

#!/bin/bash
echo Content-type: text/html
echo ""
goaccess -f /var/www/log/access.log -a | tee

Which runs perfectly on the command line (generates HTML output for access.log), but when I run it as a CGI via the URL, the output isn't the HTML I'm expecting from GoAccess web analyzer but rather:

GoAccess - 0.7 

Usage: goaccess -f log_file [-c][-r][-m][-h][-q][-d][...]

The following options can also be supplied to the command: 
       -f - Path to input log file.
<snipped>

It is as if it's running goaccess without any parameters. Either that, or the parameters I specify in my Bash CGI aren't being seen for whatever reason.

I'm at the end of my wits. Any people w/some CGI experience that can help?

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250

1 Answers1

2

Apparently, if you use -f to specify the log file a check is done to see if stdin is an interactive tty and if not, the program exists. From goaccess.c (line 792 for version 0.7):

if (conf.ifile != NULL && !isatty (STDIN_FILENO))
    cmd_help ();

Using cat to send the log file through a pipe does work, but I also needed to specify where a config file could be found:

cat /var/www/log/access.log | goaccess -p /home/brm/.goaccessrc -a
brm
  • 991
  • 6
  • 7