Connecting Tech Pros Worldwide Help | Site Map

Looking for a good way to detect server platform

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 10:48 AM
Colin McKinnon
Guest
 
Posts: n/a
Default Looking for a good way to detect server platform

Hi,

I'm currently writing a wee library tool in PHP. It generates a few
(actually a lot) of temporary files and directories, so I need to setup
some garbage collection. I can do this a lot more effeciently from the
shell on a POSIX system than writing lots of PHP code, but the former wont
to work if someone tries to run it on a different platform.

(If on Unix/Linux/... I can use 'at now' to sperate the process group, and
use 'find' to delete the aged files).

Anybody got any hot tips on how to detect the platform? (I guess I could
search the $PATH for 'at' and 'find' but I was looking for a quicker fix)

TIA

C.

  #2  
Old July 17th, 2005, 10:48 AM
Steve
Guest
 
Posts: n/a
Default Re: Looking for a good way to detect server platform


The predefined constant PHP_OS holds the value 'WINNT', 'LINUX', etc as
appropriate...

---
Steve

  #3  
Old July 17th, 2005, 10:49 AM
Colin McKinnon
Guest
 
Posts: n/a
Default Re: Looking for a good way to detect server platform

Steve wrote:
[color=blue]
>
> The predefined constant PHP_OS holds the value 'WINNT', 'LINUX', etc as
> appropriate...[/color]

Ta,

C.
  #4  
Old July 17th, 2005, 10:49 AM
steve
Guest
 
Posts: n/a
Default Re: Looking for a good way to detect server platform

"Colin McKinnon1" wrote:[color=blue]
> Hi,
>
> I'm currently writing a wee library tool in PHP. It generates
> a few
> (actually a lot) of temporary files and directories, so I need
> to setup
> some garbage collection. I can do this a lot more effeciently
> from the
> shell on a POSIX system than writing lots of PHP code, but the
> former wont
> to work if someone tries to run it on a different platform.
>
> (If on Unix/Linux/... I can use 'at now' to sperate the
> process group, and
> use 'find' to delete the aged files).
>
> Anybody got any hot tips on how to detect the platform? (I
> guess I could
> search the $PATH for 'at' and 'find' but I was looking for a
> quicker fix)
>
> TIA
>
> C.[/color]

this is how I do it

$cwd = getcwd(); //get working directory
if (strstr($cwd, ":")) it is Windows....

--
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/PHP-good-det...ict189356.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz.com/eform.php?p=639934
  #5  
Old July 17th, 2005, 10:49 AM
Andy Hassall
Guest
 
Posts: n/a
Default Re: Looking for a good way to detect server platform

On 19 Jan 2005 16:20:42 -0500, steve <UseLinkToEmail@dbForumz.com> wrote:
[color=blue]
>$cwd = getcwd(); //get working directory
>if (strstr($cwd, ":")) it is Windows....[/color]

andyh@server:~/tmp$ mkdir :
andyh@server:~/tmp$ ls -ld :
drwxr-xr-x 2 andyh users 4096 2005-01-19 21:22 :/
andyh@server:~/tmp$ uname -a
Linux server 2.4.26 #1 Wed Oct 27 19:32:01 BST 2004 i586 unknown unknown
GNU/Linux

:-p

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
  #6  
Old July 17th, 2005, 10:49 AM
steve
Guest
 
Posts: n/a
Default Re: Re: Looking for a good way to detect server platform

"Andy Hassall" wrote:[color=blue]
> On 19 Jan 2005 16:20:42 -0500, steve
> <UseLinkToEmail@dbForumz.com> wrote:
>[color=green]
> >$cwd = getcwd(); //get working directory
> >if (strstr($cwd, ":")) it is Windows....[/color]
>
> andyh@server:~/tmp$ mkdir :
> andyh@server:~/tmp$ ls -ld :
> drwxr-xr-x 2 andyh users 4096 2005-01-19 21:22 :/
> andyh@server:~/tmp$ uname -a
> Linux server 2.4.26 #1 Wed Oct 27 19:32:01 BST 2004 i586
> unknown unknown
> GNU/Linux
>
> :-p
>
> --
> Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
> <http://www.andyhsoftware.co.uk/space> Space: disk usage
> analysis tool[/color]

Hi Andy,

Ok, I did not know you can insert ":" into a unix path. I would
never have that situation with my paths, since they are totally under
my control -for webserving. In any case, the use of PHP_OS is a lot
better.

--
Posted using the http://www.dbforumz.com interface, at author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbforumz.com/PHP-good-det...ict189356.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbforumz.com/eform.php?p=640400
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.