Phpexec () a shell error occurs because grep in php can only process text streams, but binary streams cannot.

Source: Internet
Author: User
Failed | & nbsp; grep & nbsp; 'startup' & nbsp; | wc-l test in the linux command line. No problem occurs in a shell result of php exec, the reason is that grep in php can only process text streams, but binary streams cannot.
Cat aa.txt | grep 'startup' | wc-l is available in linux command lines. But the exec in php has a problem, which is strange. Result: the following error occurs: cat: write error: Broken pipe.

I spent a lot of effort, checked a lot of information, and finally solved the problem. -A option is added to the grep option.
The grep-a option indicates Process a binary file as if it were text; this is equivalent to the -- binary-files = text option

It should be cat. The file contains a binary stream, which causes grep to not recognize it.

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.