Bug #77645 [Opn->Nab]: Error in the exec function

From: Date: Fri, 14 Jun 2019 12:11:05 +0000
Subject: Bug #77645 [Opn->Nab]: Error in the exec function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221311@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77645&edit=1 ID: 77645 Updated by: sjon@php.net Reported by: ailiangkuai at qq dot com Summary: Error in the exec function -Status: Open +Status: Not a bug Type: Bug Package: Unknown/Other Function Operating System: CentOS release 6.8 (Final) PHP Version: 7.1.26 -Assigned To: +Assigned To: sjon Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2019-02-21 09:40:44] ailiangkuai at qq dot com Description: ------------ --- From manual page: https://php.net/function.system --- 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: --------------- <?php $lastOutput = exec("gunzip < /backup-files/test.sql.gz | mysql -u*** -p'***' --host=localhost --database=test",$output,$return_var); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77645&edit=1

« previous php.bugs (#221311) next »