What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.



system — Executes command cmd in the system's command interpreter and returns the last line of output. An optional argument allows the return value to be captured.


string system(cmd);
string cmd: Command to be executed variable$return_value Variable in which to store the return value of the command Variable in which to store the return value of the command


Last line of output from command cmd; FALSE if the command cannot be run


system() attempts to execute cmd in the system's command interpreter. PHP waits until the command interpreter returns before execution of the script continues past the call to system() .

Output from the command is sent directly to stdout.

If the return_value argument is set, the return value of the command is stored in this variable.


PHP 3+; PHP 4+


Example 1099. Use passthru() to display recent errors from the Apache error log for a specific user

// this script is for UNIX-like operating systems

// Set the location to an apache error log
$error_log = '/var/www/logs/error_log';

// Find who the owner of this script is
// Find out the owner's username, home directory, and other details
$user = posix_getpwuid (fileowner ($SCRIPT_FILENAME));

    Use shell commands to parse an apache error_log for
    entries that have the user's home directory in them
    For more information on tail and grep, see your system man pages

passthru ("tail -n 1000 $error_log | grep $user[dir]");

Example 1100. Display all entries for a specific directory from the current IIS log file

// This script is for NT and Windows 2000 Professional/Server products only

    Set the term to search for. In this case, we're looking for the root directory 'bugs'
    Note the double quotes inside the single quotes. 
    Find requires that the search term be quoted by double quotes.
$search_term = '" /bugs/"';

// Create a name for the current date's log file
$log_file_name = 'EX' . gmdate ('ymd') . '.log';

// Use the Find command to search through the log file for $search_term
system ("find $search_term %WinDir%\\System32\\LogFiles\\W3SVC1\\$log_file_name");


PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at The authors of this book have elected not to choose any options under the OPL. This online book was obtained from and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.