PDA

For continued disscussion on this topic : Detecting the BeOS



Kevin Ar18
08-24-2000, 05:09 AM
I want something that can log when a user visits my site using the BeOS.

If possible, even detect what browser.

Using javascript, navigaor.userAgent returns the following in Opera for the BeOS
Mozilla/4.0 (BeOS R4.5;US) Opera 3.60 (en)
I have yet to test things in Netpositive, perhaps someone could try that.
And Mozilla is not compiling right yet, so you can't really test that.

The following javascript code returns true (thus detecting if the user is running the BeOS:
var isBeOS = (agt.indexOf("beos") != -1);

Now, Is there any way to log when a user visits using the BeOS? I'm thinking a cgi script would be best for this. I'm not sure if any javascript would be needed, but I included the info, just in case it would be of use.
Here was the javascript dicussion on another thread:
http://www.webxpertz.net/forums/showthread.php?threadid=768

Kool Dude
08-24-2000, 05:19 AM
Good question, I'm thinking it is possible, just not sure at the moment. I'll see what I can find out, it may be an environment variable you can use. :)

Kevin Ar18
08-24-2000, 04:16 PM
None of the stats programs I've tried will log the BeOS, so I guess we have to do it ourselves. :)

Perhaps there's a way to edit a stats program at http://www.cgi-resources.com/ to detect the BeOS as well?

Anyways, if not, all I would need is something simple, that say writes to a file on the server when someone with the BeOS visits.
For example, everytime someone visits it's write something like the following to the file (on a new line)

BeOS 4.5, Opera 3.60, 24.256.243.188, August 24, 2000

Kool Dude
08-24-2000, 05:15 PM
I think the info would be in the env. variable

HTTP_USER_AGENT

So maybe something like:

$theuser= $ENV{'HTTP_USER_AGENT'};
if ($theuser=~ /.*BeOS.*/)
{
$filetoupdate='beusers.cgi';
open(DAT, >>$filetoupdate);
print DAT "$theuser\n";
close(DAT);
}

Maybe, not sure if I have it all right on the fly here though. :)

Kevin Ar18
08-25-2000, 05:01 AM
Ok, your gonna have to help me understand this a little, I've edited cgi-scripts, but that's about it.

The code you gave me, was that for a cgi script?
or a javascript to insert in the page?

Kool Dude
08-26-2000, 11:06 PM
It was a bit of Perl for a CGI script.

I think the whole thing would look somethin' like this:

-------------
#!/usr/bin/perl

$theuser= $ENV{'HTTP_USER_AGENT'};
if ($theuser=~ /.*BeOS.*/)
{
$filetoupdate='beusers.cgi';
open(DAT, >>$filetoupdate);
print DAT "$theuser\n";
close(DAT);
}
-------------

You'd need to change the first line if that is not the path to Perl on your server, the one I put is most common though.

Change the $filetoupdate variable to the name of the file you want to write the info. to. If you want an HTML or txt file instead of cgi it will work, but can be viewed by anyone.

If you have alot of visitors we may have to add file locking to it to keep 2 people from writing to the file at once.

Test this first though as I may have an error, then we'll see what it does and what needs a' fixin'. :)