PHP and Python are two of the most widely used website programming languages.
And I think Python is the best glue for concatenating different languages in one
project. Recently, I used these two languages frequently. I want to summarize
one particular function which can execute external command. For example,
sometimes we need to process a data by other program or script. Under this
scenario, we should use a function to call external command and execute it to do
further analysis. I am only familiar with these two, so I can introduce them in
details.

PHP

Before introducing the execution function, we would better to pay attention to
the settings in php.ini. This file have some configurations to control the
execution of external command. Normally, in Ubuntu, the php.ini is located in
/etc/php5/apache2/php.ini if you are using Apache as front server. These
settings we should note:

If we want to wait the external program until it is end, we should pay attention
the max_execution_time. Sometime, the time may exceed the default time limit.
The second one is safe mode which can
run the program located in some specified directories. The third one is some
dangerous command you want to disable, such as fork, rm, …, etc.

exec(), system() and passthru()

These three function can be used to execute external program in PHP. You can see
the usage of these three function in PHP manual. The difference
between these is:

They have slightly different purposes. exec() is for calling a
system command, and perhaps dealing with the output yourself. system() is for
executing a system command and immediately displaying the output - presumably
text. passthru() is for executing a system command which you wish the raw return
from, presumably something binary.