greetings,
i'm a php and html novice and i figured i'd learn by diving in. i've written a php script that i've placed in the /var/www/html directory. it's supposed to give some relative info about the system when you point a browser at it. if i run the script using "php -q index.php" all the retrieved values are there, however when you point a browser at it the Hardware, Serial Number and Processor(s) values are blank. any suggestions(hints also appreciated) as to why the values are absent in the browser but present when run manually would be appreciated. i used `` rather than shell_exec to save on typing. while i'm sure there are other ways to do this and possibly smarter, you have to start somewhere:
<?php
$hostname = `hostname`;
$manufacturer = `dmidecode | grep Manufacturer | head -1 | cut -d: -f2`;
$model = `dmidecode | grep 'Product Name' | head -1 | cut -d: -f2`;
$serialno = `dmidecode | grep 'Serial Number' | head -1 | cut -d: -f2`;
$location = `cat /etc/snmp/snmpd.conf | grep syslocation | awk '{for (i=2; i<NF; i++) printf \$i " "; print \$NF}'`;
$contact = `echo "Contact Information: me at 734-555-5555"`;
$kernelarch = `uname -srvm`;
$processor = `dmidecode -s processor-version | head -1`;
$opsys = `cat /etc/redhat-release`;
$numprocessor = `cat /proc/cpuinfo | grep -c processor`;
$memtotal = `cat /proc/meminfo | grep MemTotal | awk '{print $2}'`;
$memvaluetotal = `expr $memtotal / 1000`; //i'm sure php can do math but that's for later
$memfree = `cat /proc/meminfo | grep MemFree | awk '{print $2}'`;
$memfreetotal = `expr $memfree / 1000`; //i'm sure php can do math but that's for later
$uptime = `uptime | awk '{print $3, $4}' | tr -d ,`;
?>
<p><b><u><big><?php echo $hostname;?></big></u></b><br/ >
<b>Hardware:</b><?php echo $manufacturer,$model;?><br/ >
<b>Serial Number:</b><?php echo $serialno;?><br/ ><p/ >
<p><b>Location: </b><?php echo $location;?><br/ >
<b>Contact Information: </b><?php echo $contact;?><p/ >
<p><b>Kernel and architecture: </b><?php echo $kernelarch;?><br/ >
<b>Processor(s): </b><?php echo $processor;?><br/ >
<b>Operating system: </b><?php echo $opsys;?><p/ >
<p><b>Processor total: </b><?php echo $numprocessor;?><br/ >
<b>Total memory: </b><?php echo $memvaluetotal;?>Mb<br/ >
<b>Free memory: </b><?php echo $memfreetotal;?>Mb<p/ >
<p><b>UpTime: </b><?php echo $uptime;?><br/ ><p/ >
the browser looks something like this:
t70cfd101
Hardware:
Serial Number:
Location: York Cab #C205
Contact Information: me at 734-555-5555
Kernel and architecture: Linux 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64
Processor(s):
Operating system: Red Hat Enterprise Linux Server release 5.4 (Tikanga)
Processor total: 8
Total memory: 49456556 Mb
Free memory: 4154896 Mb
UpTime: 459 days
and running the php script on the command line looks like:
sh: line 1: /: is a directory
sh: line 1: /: is a directory
<p><b><u><big>t70cfd101
</big></u></b><br/ >
<b>Hardware:</b> HP
ProLiant BL280c G6
<br/ >
<b>Serial Number:</b> USE0293K8C
<br/ ><p/ >
<p><b>Location: </b>York Cab #C205
<br/ >
<b>Contact Information: </b>me at 734-555-5555<p/ >
<p><b>Kernel and architecture: </b>Linux 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64
<br/ >
<b>Processor(s): </b>Intel(R) Xeon(R) CPU X5570 @ 2.93GHz
<br/ >
<b>Operating system: </b>Red Hat Enterprise Linux Server release 5.4 (Tikanga)
<p/ >
<p><b>Processor total: </b>8
<br/ >
<b>Total memory: </b>49456556
Mb<br/ >
<b>Free memory: </b>4154888
Mb<p/ >
<p><b>UpTime: </b>459 days
<br/ ><p/ >
thanks in advance.