473,800 Members | 2,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Jul 17 '05 #1
5 3458

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

---
Steve

Jul 17 '05 #2
Steve wrote:

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


Ta,

C.
Jul 17 '05 #3
"Colin McKinnon1" wrote:
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.


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
Jul 17 '05 #4
On 19 Jan 2005 16:20:42 -0500, steve <Us************ @dbForumz.com> wrote:
$cwd = getcwd(); //get working directory
if (strstr($cwd, ":")) it is Windows....


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 / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #5
"Andy Hassall" wrote:
On 19 Jan 2005 16:20:42 -0500, steve
<Us************ @dbForumz.com> wrote:
$cwd = getcwd(); //get working directory
if (strstr($cwd, ":")) it is Windows....


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 / <an**@andyh.co. uk> / <http://www.andyh.co.uk >
<http://www.andyhsoftwa re.co.uk/space> Space: disk usage
analysis tool


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
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
3758
by: Lauren Wilson | last post by:
Does anyone know how the following info is extracted from the user's computer by a Front Page form? HTTP User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0 I only ask because I believe I could use the same info as part of a scheme to generate a unique (or at least less common) serialized id code for the user's computer as part of a software locking and activation system. If I had a DLL...
1
2841
by: oreng | last post by:
Hey all, I have some problems detecting whether the client's browser javascript is enabled at the server side. While Request.Browser.JavaScript only check if the browser enable java script (and so on with Request.Browser.Cookies). I saw some server controls that register a startup script on the page_load and then perform a postback and run the javascript,changing a hidden
4
2022
by: tony | last post by:
I'm designing a survey form page that will be fairly complex and am becoming confident enough with PHP now to tackle most things. (Thanks to everyone here who has helped) Before I go too far with this I was wondering if anyone could perhaps offer advice or point me to any documents/web pages that could help with ensuring the security of the form/page and site. It is likely that the form will come under attack I expect. Even comments...
21
3780
by: The Night Blogger | last post by:
Can someone recommend me a good API for writing a sexy looking (Rich UI like WinForms) shrink wrap application My requirement is that the application needs to look as good on Windows as on the Apple Mac
13
1062
by: Avi | last post by:
Hi, Is there a UNIX C system command that will let me copy a file? I am looking for something similar to "cp" that can be called within a C program. I know of the "link" system call but this command will set a the second file as a link to the first file rather than an independent copy of the first file. (Windows has the CopyFile command but I didn't find anything that would work under UNIX)
3
1749
Airslash
by: Airslash | last post by:
Hello, me and 2 fellow students are busy working on our endterm project at school. The assignment consists of a cross platform multimedia application (a game in our project) that can be compiled on Windows, Linux or Apple. We have extended our client to have online capababilities, but I'm having trouble finding decent information about making cross platform TCP or UDP connections to a server. I know there is SDL_NET to use as it's a good...
7
1476
by: Brent White | last post by:
We're looking into building an in-house integrated enterprise system to manage inventory, work-in-process, and finances, among others. I am somewhat familiar with VB.NET (veteran VB 6 programmer) and think that using the .NET framework would be best. What programming language is ideal for programming in the .NET framework, just overall, and what has been people's experiences taking on a massive project like this? Right now, we use a...
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.