Using PHP for system commands

Jun 14, 2009 Author: SEO

PHP can interact with your operating system to perform any task the operating
system can perform. You can execute an operating system command and
receive the output. For example, you can execute a dir or ls command (to
list the files in your directory) from PHP and receive the list of filenames that
the dir/ls command produces.The ability to execute system commands is often useful for system administrative
and maintenance tasks. For example, you may want to clean up a
directory by deleting files with a particular extension. You can use a system
command to get a list of files in a directory and then identify and delete the
files with the unwanted extension.
The ability to execute system commands includes the ability to run any other
program on the system. Thus, you can run programs in other languages from
PHP and make use of the output. Aren’t you relieved that you don’t have to
rewrite all those programs you’re using now? You can run Perl, C, shell scripts,
or any other language programs from PHP. New PHP programs can add functionality
to your system tools, without requiring you to spend time rewriting
existing tools.

views 3605
  1. Add New Comment