4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 PHP repeating output of system()
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Thu Mar 04, 2004 2:36 pm (13 years, 7 months ago) Reply with QuoteBack to Top

I've just noticed something odd. I have the following script to provide some stats about my pc:
Code:
<?php
print '<p><strong>Uptime:</strong> ';
print system('uptime').'</p>';
print '<p><strong>Logged in Users:</strong></p><blockquote><pre>';
print system('who').'</pre></blockquote>';
print '<p><strong>Services:</strong></p><blockquote><pre>';
print system('rc-status').'</pre></blockquote>';
print '<p><strong>Disk Usage:</strong></p><blockquote><pre>';
print system('df -h').'</pre></blockquote>';
?>


for some reason, it prints the last line output by system() twice, as below:
Quote:
Uptime: 14:27:44 up 4:48, 2 users, load average: 1.28, 1.92, 2.51 14:27:44 up 4:48, 2 users, load average: 1.28, 1.92, 2.51

Logged in Users:

adam :0 Mar 4 11:21
adam pts/1 Mar 4 13:06 (:0.0)
adam pts/1 Mar 4 13:06 (:0.0)

Services:

Runlevel: default
xdm [ started ]
sshd [ started ]
local [ started ]
mysql [ started ]
vixie-cron [ started ]
domainname [ started ]
esound [ started ]
net.wlan0 [ started ]
sysklogd [ started ]
netmount [ started ]
usermin [ started ]
webmin [ started ]
apache2 [ started ]
hotplug [ started ]
setiathome [ started ]
mldonkey [ started ]
pure-ftpd [ started ]
pure-ftpd [ started ]

Disk Usage:

Filesystem Size Used Avail Use% Mounted on
/dev/hdb3 8.6G 5.7G 2.9G 67% /
/dev/hda1 17G 4.6G 12G 29% /home
none 189M 0 189M 0% /dev/shm
none 189M 0 189M 0% /dev/shm


I'm pretty sure this must be a bug in php, does anyone know anything about it?

(using apache 2.0.48 and php 4.3.4)

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
adam
Forum Moderator & Developer



Joined: 26 Jul 2002
Posts: 704
Location: UK

PostPosted: Thu Mar 04, 2004 2:39 pm (13 years, 7 months ago) Reply with QuoteBack to Top

ok, I've figured it out already Laughing things printed to stdout by system() are sent to the browser straight away, as well as being returned by the function. *sigh*

________________________________
It's turtles all the way down...
OfflineView User's ProfileFind all posts by adamSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.053354 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme