Msn web hosting - Chapter 16: Command-Line PHP Utilities 587 You can

Chapter 16: Command-Line PHP Utilities 587 You can see www.csus.com (California State University, Sacramento) appears to be located in Sacramento, CA, U.S., which makes sense. This script should be used from the command line as needed. However, if you wish to make it available to everyone, you can install it in /usr/bin, which is typically in any user s path. Here is how: 1. Make a directory called /usr/local/src/php/gelocator and copy the netgeo.php class into that directory. Make sure the directory is r+x by all users. In addition, make sure netgeo.php is readable by all users, but neither should be writable. 2. Copy geolocator.php into /usr/bin as geolocator. We remove the php extension because executable scripts typically do not need extensions. 3. Modify /usr/bin/geolocator such that require_once( netgeo.php ) now is require_once( /usr/local/src/php/geolocator/netgeo.php ). This will ensure that when users run geolocator from the command line, the /usr/bin/geolocator script will find the netgeo.php class. Now you and your users can run geolocator from anywhere. Note that the geolocator script is fairly accurate, but its output should not be used as a final (and perhaps critical) determination of a particular host s location. Building a Hard Disk Usage Monitoring Utility Now we will develop a hard disk usage monitoring tool that uses Linux proc file system information to determine hard disk usage, and if usage for a given mounted file system exceeds a specified percentage, the utility sends an e-mail message to the administrator. The script we will develop here requires the classLinux.inc.php and common_functions.php classes from the phpSysInfo project, which is located at http://phpsysinfo.sourceforge.net/project. Download the phpSysInfo project and you will find the common_ functions.php in the main distribution directory; the class.Linux. inc.phpcan be found in the os subdirectory within the includes directory.

Leave a Reply