Question

I've been looking into different web statistics programs for my site, and one promising one is Visitors. Unfortunately, it's a C program and I don't know how to call it from the web server. I've tried using PHP's shell_exec, but my web host (NFSN) has PHP's safe mode on and it's giving me an error message.

Is there a way to execute the program within safe mode? If not, can it work with CGI? If so, how? (I've never used CGI before)

Was it helpful?

Solution 5

I managed to solve this problem on my own. I put the following lines in a file named visitors.cgi:

#!/bin/sh

printf "Content-type: text/html\n\n"
exec visitors -A /home/logs/access_log

OTHER TIPS

Visitors looks like a log analyzer and report generator. Its probably best setup as a chron job to create static HTML pages once a day or so.

If you don't have shell access to your hosting account, or some sort of control panel that lets you setup up chron jobs, you'll be out of luck.

Is there any reason not to just use Google Analytics? It's free, and you don't have to write it yourself. I use it, and it gives you a lot of information.

Sorry, I know it's not a "programming" answer ;)

I second the answer of Jonathan: this is a log analyzer, meaning that you must feed it as input the logfile of the webserver and it generates a summarization of it. Given that you are on a shared host, it is improbable that you can access to that file, and even if you would access it, it is probable that it contains then entries for all the websites hosted on the given machine (setting up separate logging for each VirtualHost is certainly possible with Apache, but I don't know if it is a common practice).

One possible workaround would be for you to write out a logfile from your pages. However this is rather difficult and can have a severe performance impact (you have to serialize the writes to the logfile for one, if you don't want to get garbage from time to time). All in all, I would suggest going with an online analytics service, like Google Analytics.

As fortune would have it I do have access to the log file for my site. I've been able to generate the HTML page on the server manually - I've just been looking for a way to get it to happen automatically. All I need is to execute a shell command and get the output to display as the page.

Sounds like a good job for an intern.

=)

Call your host and see if you can work out a deal for doing a shell execute.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top