LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-19-2002, 02:33 AM   #1
bkeating
Member
 
Registered: Mar 2002
Location: San Francisco, CA
Distribution: Open/FreeBSD, Gentoo, SuSE
Posts: 511

Rep: Reputation: 38
Uptime posted to html via PHP?


Anyone know the command to post system uptime to a page?

Would like to post it on my front page. Isn't is like $PHP_Uptime er something? im looking but haven't found anything yet. Oh, except to echo end-users browser/os type neat stuff.
 
Old 06-19-2002, 06:30 AM   #2
Shak
Member
 
Registered: May 2002
Location: Huddersfield
Distribution: Redhat (7.2, 7.3, 8.0), Debian, Slackware, Gentoo, FreeBSD
Posts: 169

Rep: Reputation: 30
http://freshmeat.net/projects/phpuptime/?topic_id=862

reports the uptime, and makes it an image, you could edit the script

Shak
 
Old 06-19-2002, 10:28 AM   #3
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
That's pretty nicely done. The only problem is it doesn't extract the number of days properly. The number of days doesn't always start on the 13th character. And it only reads 2 characters meaning you could never have an uptime greater then 99 days. But it shouldn't be too hard to modify that. You could remove the line $uptime = (exec("uptime"));
and replace the $up = line with the following one:

$up = (exec("uptime | sed 's/.*up //' | sed 's/ days.*//'"));

Haven't tried it out but something like that should work.
 
Old 06-19-2002, 04:11 PM   #4
skeletal29
Member
 
Registered: Apr 2002
Location: Nyc
Distribution: Gentoo
Posts: 127

Rep: Reputation: 15
use phpsysinfo.

it will look like

http://skeletal29.homelinux.net/sysinfo/
 
Old 06-19-2002, 05:46 PM   #5
bkeating
Member
 
Registered: Mar 2002
Location: San Francisco, CA
Distribution: Open/FreeBSD, Gentoo, SuSE
Posts: 511

Original Poster
Rep: Reputation: 38
got it!


<?php
$fp = popen("/usr/bin/uptime", "r");
while($line = fgets($fp, 1024)):
printf("%s<br>\n", $line);
endwhile;
pclose($fp);
?>

works for me! but im interested in others thanks for the replies
 
Old 06-20-2002, 03:51 AM   #6
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Well since the output of uptime is just one line, and you want to display the whole line anyway. Why don't you change it to:

<?php
$up = exec("/usr/bin/uptime");
printf("%s<br>\n", $up);
?>
 
  


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
html into php charnel Programming 7 08-30-2005 10:47 AM
PHP/html forum FedoraUsr Programming 2 08-18-2005 01:07 PM
HTML/PHP question perfect_circle Programming 2 04-22-2005 11:42 AM
html to php? help me please!!!!! trscookie Programming 4 01-24-2005 06:36 AM
HTML Tidy and PHP 4 atom Programming 0 10-01-2004 10:06 AM


All times are GMT -5. The time now is 02:43 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration