|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77645 Error in the exec function
Submitted: 2019-02-21 09:40 UTC Modified: 2019-06-14 12:11 UTC
From: ailiangkuai at qq dot com Assigned: sjon (profile)
Status: Not a bug Package: Unknown/Other Function
PHP Version: 7.1.26 OS: CentOS release 6.8 (Final)
Private report: No CVE-ID: None
 [2019-02-21 09:40 UTC] ailiangkuai at qq dot com
From manual page:
i want execute linux shell via php.if the shell works fine,the $output will be filled with every line of output from the shell script.but if shell script has error,$output is filled whith nothing. i have used the func of python which is commands.getoutput,Get the result regardless of whether the script has an error.

Test script:
$lastOutput = exec("gunzip < /backup-files/test.sql.gz | mysql -u*** -p'***' --host=localhost --database=test",$output,$return_var);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-14 12:11 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: sjon
 [2019-06-14 12:11 UTC]
If you want to return errors, you should append 2>&1 to your command - as all system calls do not include stderr in their output by default.
You could also switch to proc_open which allows you to retrieve stderr separately
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed May 18 10:05:45 2022 UTC