PHP exec () function no return value troubleshooting method [Go]

Source: Internet
Author: User
Tags vars

Installation fails on many servers that need to be used to exec security imagemagic

EXEC () failed to execute the external command, but there is no error message.

EXEC executes a command at the command line without problems, but in PHP there is an error. This issue 99.99% is related to permissions, but the command that exec executes does not return an error. One trick is to use the pipe command, assuming your exec call is as follows:

    1. EXEC (' convert a.jpg b.jpg ', $output, $return _val);

Can be changed as follows:

    1. EXEC (' convert a.jpg b.jpg 2>&1 ', $output, $return _val);
    2. Print_r ($output);

With 2>&1, the command outputs the error from the execution of the shell to the $output variable, which can be analyzed by outputting the variable.

Note: Exec has 3 parameters, the first is the command to execute, the second is an array, the value of the array is generated after the first command executes, the third parameter executes the state, 0 indicates success, and the others indicate failure.

In PHP There are a total of three functions that can be used to execute external command system,exec,passthru.

Transfer from http://blog.csdn.net/aoyoo111/article/details/21049759

For more wonderful posts, please go to a blog with a salty message.

Website: http://blog.csdn.net/aoyoo111

PHP exec () function no return value troubleshooting method [Go]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.