OS Detection

Open discussions on further developing and promoting Coranto, and getting back into the mainstream.
All thoughts and comments are welcome, no matter your specialty.

Moderators: Spunkmeyer, Dale Ray, Jackanape, SrNupsen, Bluetooth

OS Detection

Postby cerberos76_ » Sat Dec 04, 2004 4:34 pm

Hi,
I would like to have a very small and simple routine to detect the current used server OS to be ablet to do some simple statistics. The parameter will be passed back as part of the image string in the 'current version' verification.

This is what I have now (from past projects):
#platform (win or unix) detection)
if ($ENV{'SHELL'}){
$platform = ($ENV{'SHELL'} =~ m|^/|) ? 'Unix' : 'Windows'; }
else {
$os1= $^O; $os2= $ENV{'OS'};
$platform = ($os1 eq 'MSWin32' || $os2 =~ /window/i) ? 'Windows' : 'Unix';
}

Do you know any way to detect MAC OS?
I know you could also write a similar thing from the $ENV{'HTTP_USER_AGENT'}, but usually you en up with a long elsif list...
If you have some code snippet which you tested and is reasonably compact, please pass it on.
Coranto addons:
* GuestPost, one click guestposting
* MoveIt!, Advanced Backup and site transfer
* PartialRebuild, CPU-friendly enhancement of FullBuild
* URLColumn, URLs for multiple Categories/Profiles
* Tickit!, Javascript News Tickers/Faders for Coranto!
* AddonEnabler, enables or disables single, multiple or all addons in one go
* SubmitMultiple, post consecutive news in an automatic loop!
* RSSAdvanced, RelatedNews ....

Get them at: http://coranto.gweilo.org/addons/
cerberos76_
 
Posts: 1339
Joined: Sun Mar 10, 2002 1:21 am

Postby LoneOwl » Sat Dec 04, 2004 10:06 pm

If you're wanting the server OS, use the Config module for a simple test script. It's a big module, and one of those instances where you wouldn't want to load it every single time, but it will have all you'll need to know, and more.
User avatar
LoneOwl
 
Posts: 1465
Joined: Sun Mar 10, 2002 2:57 am
Location: That one place, you know?

Postby cerberos76_ » Sat Dec 04, 2004 10:57 pm

Yes, the problem is I just with to keep that very small and low weight.Do you know what value $^O returns when run on a mac os?

I think I will use the $ENV{'HTTP_USER_AGENT'} anyway, as it is realible enough most of the time...
Coranto addons:
* GuestPost, one click guestposting
* MoveIt!, Advanced Backup and site transfer
* PartialRebuild, CPU-friendly enhancement of FullBuild
* URLColumn, URLs for multiple Categories/Profiles
* Tickit!, Javascript News Tickers/Faders for Coranto!
* AddonEnabler, enables or disables single, multiple or all addons in one go
* SubmitMultiple, post consecutive news in an automatic loop!
* RSSAdvanced, RelatedNews ....

Get them at: http://coranto.gweilo.org/addons/
cerberos76_
 
Posts: 1339
Joined: Sun Mar 10, 2002 1:21 am

Postby LoneOwl » Sun Dec 05, 2004 2:10 am

If I recall right...
Code: Select all
$^O =~ /Mac/ or $^O =~ /darwin/ and $IsMac = 1;
User avatar
LoneOwl
 
Posts: 1465
Joined: Sun Mar 10, 2002 2:57 am
Location: That one place, you know?


Return to Coranto Round Table

Who is online

Users browsing this forum: No registered users and 0 guests

cron