View Full Version : OS command in php
KrisDwyer
July 29th, 2005, 11:10 AM
Hey,
Just Out of interest is there a command that prints what os you are running? Just interested...
Kris
dave9191
July 29th, 2005, 11:55 AM
Well you could try printing out the enviromental varible "TERM".
Or you can run a shell command "uname -a".
Dave
TomB
July 29th, 2005, 01:45 PM
<?php echo system("uname -a"); ?>
dare2dreamer
July 29th, 2005, 01:50 PM
http://us3.php.net/manual/en/function.exec.php
Just remember that the web server runs as its own user, so you'll need to make sure whatever applications you want to run have appropriate permissions. (A potential security risk)
I build a headless server at one point which allowed a web page to shut down and reboot the server, I gave user www-data sudo permissions with no password on one command, /usr/sbin/shutdown.
see man sudoers for details.
odyniec
July 30th, 2005, 08:02 AM
Try php_uname().
http://www.php.net/manual/en/function.php-uname.php
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.