ID: 22744 Updated by: [EMAIL PROTECTED] Reported By: tim at timcrider dot com -Status: Open +Status: Feedback Bug Type: Performance problem Operating System: Red Hat 8.0 PHP Version: 4.3.2RC1 New Comment:
http://www.php.net/manual/en/function.exec.php The second parameter will be filled with each line of the command. I'm still interested to hear what the size of the data is: echo strlen($sys); Previous Comments: ------------------------------------------------------------------------ [2003-03-18 13:03:40] tim at timcrider dot com I apologize again. This is what 'works.php' SHOULD look like: ---[ works.php ]--- #!/bin/php <?php $mybin = "/usr/local/mysql/bin/mysqlbinlog"; $mylogpath = "/var/lib/mysql/"; $dolog = $mylogpath."towely-bin.010"; $tmpfname = tempnam ("/tmp", "mybinlogger"); $fp = fopen($tmpfname, "w"); fwrite($fp, `$mybin $dolog`); fclose($fp); $lstk = file($tmpfname); unset($tmpfname); print count($lstk)."\n"; ?> --[ End works.php ]--- ------------------------------------------------------------------------ [2003-03-18 13:02:00] tim at timcrider dot com I apologize the second script is bogus. Here is the fix: ---[ works.php ]--- #!/bin/php <?php $mybin = "/usr/local/mysql/bin/mysqlbinlog"; $mylogpath = "/var/lib/mysql/"; $dolog = $mylogpath."towely-bin.010"; $lstk = exec("mysqlbinlog $dolog"); print_r($lstk); print count($lstk)."\n"; ?> (towely) phpbug# more test.php #!/bin/php <?php $mybin = "/usr/local/mysql/bin/mysqlbinlog"; $mylogpath = "/var/lib/mysql/"; $dolog = $mylogpath."towely-bin.010"; $tmpfname = tempnam ("/tmp", "mybinlogger"); $fp = fopen($tmpfname, "w"); fwrite($fp, `$mybin $dolog`); fclose($fp); $lstk = file($tmpfname); unset($tmpfname); print count($lstk)."\n"; ?> --[ End works.php ]--- ---[ broken.php ]--- #!/bin/php <?php $mybin = "/usr/local/mysql/bin/mysqlbinlog"; $mylogpath = "/var/lib/mysql/"; $dolog = $mylogpath."towely-bin.010"; $sys = `mysqlbinlog $dolog`; $lstk = split("\n", $sys); print_r($lstk); print count($lstk)."\n"; ?> ---[ End broken.php ]--- Using exec does not give me the output that I need to do this. exec only returns the last line of the output. I'm trying to get all of the output, which has line breaks at the end of every row. I did a dump of this server using 'php -i > php_ini.txt and can be seen here. http://timcrider.com/php_ini.txt If there is anything else you need me to do let me know. Tim ------------------------------------------------------------------------ [2003-03-18 12:41:51] [EMAIL PROTECTED] Your second test script look bogus to me. Have you considered using http://www.php.net/manual/en/ref.exec.php, which gives the lines as an array anyway? How big is the logfile? Do you have magic_quotes enabled? If you leave it running, how long does it take to complete and how much memory does it use? ------------------------------------------------------------------------ [2003-03-17 09:04:26] tim at timcrider dot com split hangs for some reason, but doing the same logical process with other functions returns a very quick result. The problem is that I'm trying to process the mysqlbinlog output and parse it for easier management. The logical process is as follows. $sys = `mysqlbinlog logfile`; This part works fine, but when I try: $lstk = split("\n", $sys); the script hangs for well over 5 minutes (I kill the script at that time. However this code produces the desired results in less than 2 seconds: $mybin = "/usr/local/mysql/bin/mysqlbinlog"; $mylogpath = "/var/lib/mysql/"; $dolog = $mylogpath."towely-bin.010"; $tmpfname = tempnam ("/tmp", "mybinlogger"); $fp = fopen($fp, $tmpfname); fwrite($fp, `$mybin $dolog`); fclose($fp); $lstk = file($tmpfname); unset($tmpfname); print count($lstk)."\n"; I am using this from the command line version of php 4.3.2 RC1. Here is my php -v: PHP 4.3.2-RC1 (cli) (built: Mar 14 2003 13:28:33) Copyright (c) 1997-2003 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies with the ionCube PHP Accelerator v1.3.3r2, Copyright (c) 2001-2002, by Nick Lindridge If you need any other information please feel free to contact me at [EMAIL PROTECTED] ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22744&edit=1
