Home  >  Article  >  Backend Development  >  Using exec to call system commands in PHP

Using exec to call system commands in PHP

不言
不言Original
2018-04-26 10:23:376240browse

This article mainly introduces the use of exec to call system commands in PHP. It has certain reference value. Now I share it with everyone. Friends in need can refer to it

Ø Question: How to execute System commands or execute other files

Ø Method:

1, ModifyPHP.ini

disable_functions = exec

2, Modify permissions

Modify the script to be executed

chmod 777 home/ -R

If other files are executed, the permissions of the corresponding files and all directories above them should be changed to executable mode

3, Debugging

If the script execution fails, use the pipeline command, use 2>&1, the command will output the error during shell execution to the $output variable, and output the variable to analyze the error message

For example:

exec('convert a.jpg b.jpg', $output, $return_val);

Change to:

exec('convert a.jpg b.jpg 2>&1', $output, $return_val);
print_r($output);

Related recommendations:

php uses gearman for task distribution


The above is the detailed content of Using exec to call system commands in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn