views:

164

answers:

9

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)

+1  A: 

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.

FlySwat
A: 

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 ;)

Sam McAfee
A: 

@Jonathan Holland

Unfortunately, while NFSN does provide SSH access, they don't provide the ability to schedule cron jobs due to their "highly dynamic" service. They mention using a service that will periodically hit a page as a replacement, but I don't think this will solve my problem.

@Sam McAfee

Of course - I'm using both AWstats and Google Analytics currently, but Visitors provides some functionality unique to both of them. I'm always looking for ways to extract useful trends out of noise, so the more data aggregation I can have the better.

Kyle Cronin
A: 

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.

Cd-MaN
A: 

@Cd-MaN

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.

Kyle Cronin
A: 

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.

FlySwat
A: 

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
Kyle Cronin
A: 

Unfortunately, while NFSN does provide SSH access, they don't provide the ability to schedule cron jobs due to their "highly dynamic" service.

Highly dynamic? With that and PHP's safe mode being turned on, I'd be looking for a new host pronto. There are lots of good ones without draconian and nonsensical restrictions like that.

ceejayoz
A: 

@ceejayoz

Few web hosts offer usage-based pricing. For small websites it can save a good deal of money if you know how to optimize. For example, I've built a website for my grandmother to showcase her artwork. The site is a collection of PHP scripts that interact with a SQLite database. The artwork itself is located on Amazon's S3, and between the two I'm paying less than a dollar per month to keep it online with a light trickle of traffic.

Kyle Cronin