Posted by Ken Hagans on 02/17/06 05:17
On Mon, 13 Feb 2006 19:54:20 -0800, sarah.ali1 wrote:
> I am trying to use the php exec function to execute 2 programs, so i call
> the exec command twice. I am working on linux. It seems to work for one
> executable (which runs fast), but not the other (which is a slow
> standalone matlab application), if the php is run via a webpage. The page
> hangs for abour 10 seconds and then is done loading...if the longer
> program executed, it should take much longer.
> The details:
> -everything is chmodded to 777
> -everything works if i try to run command line (i.e php -f page.php) -the
> $output value of the exec function returns an array. if i try to print it
> to the screen it just displays "array" -i have tried exec, system,
> passthru; same problem -if i redirect stderr and stdout to a file, the
> file always comes up empty
> -i am not in safe mode
> -set_time_limit is set to 1000000
> Any suggestions?
> Also, I have been very unsucessful in trying to use passthru to dump the
> contents of the output to my webpage, in order to debug. If i run the php
> via command line, the executable returns feedback to the prompt - it
> wouold be great to see that for the webpage version...
If you're looking to display PHP errors to the browser, check your php.ini
file for display_errors = On (this is generally set to Off when in
production, for security reasons.
You indicate that your second executable takes longer to run. How much
memory does this process require? Perhaps you need to look at the
memory_limit= setting in php.ini as well. By default, this is set to 8M,
which should be plenty for most php scripts. But, if you're calling shell
executables, you _might_ want to increase it. Don't just stuff a great
big value in here hoping to "fix" your problem. Be careful to analyze
your actual memory requirements and adjust appropriately.
Regarding printing "array" to the screen, this seems to indicate that the
program did successfully return an array. Try placing the command
var_dump($array_name) in your script to see if it will show you the array
elements and their associated values. Then, you can properly expand your
script to address the elements to extract the data you need from the array.
Good luck, and be sure to tell us all about your progress.
KG Hagans Professional Services Group
[Reply to this message]