LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-14-2005, 11:51 AM   #1
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Rep: Reputation: 30
System properties in PHP?


Hello all.

I'm new to the Linux programming scene, although I've been using non-OS-specific PHP for some time.

I was just wondering: Is it possible to return values using PHP such as system uptime, kernel version, free memory, cpu load and so on?

Ideally, there would be a variable containg all of these things in one handy place.
Is there?
 
Old 02-14-2005, 02:04 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
You could just use the reversed quotes like a shell script,
PHP Code:
$uptime=`uptime`;
echo 
"$uptime\n"
 
Old 02-14-2005, 02:35 PM   #3
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Original Poster
Rep: Reputation: 30
Wow, I didn't know you could do that.

Is this what's meant by 'magic quotes', or am I thinking of something totally different?

This functionality has taken me completely by surprise
Are there any other significant ones?
How do they work?
How uniform are they throughout different coding languages?

And to think, I was beginning to consider meself less of a newbie

[EDIT:]
Ah, I understand now - it's executing the program 'uptime' except in a way that leaves the output usable as a string. I was thinking it was something along the lines of an environment variable

Last edited by Napalm Llama; 02-14-2005 at 05:39 PM.
 
Old 02-14-2005, 05:59 PM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
More infos : http://www.php.net/manual/en/languag....execution.php

You could also use system()
 
Old 02-15-2005, 04:42 AM   #5
Napalm Llama
Member
 
Registered: Nov 2004
Location: Bristol, UK
Distribution: Gentoo 2005.0
Posts: 224

Original Poster
Rep: Reputation: 30
I tried that for getting the kernel version, but the trouble is it echoes the result straightaway.

My problem was that I didn't know uptime was a program - I thought it was some sort of keyword that if you enclosed in those special quotes, would magically give you a string telling you how long the system's been running.

I'm guessing those 'reversed quotes' are common across most C-like languages then, right?

Hey, I wonder if javascript'll do it in iexplore

*runs of to Wine installation*
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
system properties maximyus Linux - Newbie 2 06-05-2005 03:07 AM
php adduser thru system() chetshot Linux - Software 1 05-02-2005 05:00 PM
php squirrelmail system() mhatre kedar Programming 0 04-15-2005 02:33 AM
system properties configuration gui listing Buddy213 Linux - General 3 04-13-2004 09:41 PM
php and system() Marble Linux - Security 5 07-09-2003 08:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration