tags:

views:

3304

answers:

5

Hello,

I am doing the following in PHP:

exec('java -jar "/opt/flex3/lib/mxmlc.jar" +flexlib "/opt/flex3/frameworks" MyAS3App.as -default-size 360 280 -output MyAS3App.swf');

When I run this from the command line, it runs fine and finishes in a second or two.

When I run this command from PHP exec, the java process takes 100% CPU and never returns.

Any ideas?

I have also tried running the above command with '/usr/bin/java -Djava.awt.headless=true'.

I am running Mac OS X 10.5.5, MAMP 1.7, PHP 5.2.5

+1  A: 

Is there a reason why your using the mxmlc jar file to compile your flex application? have you tried using the executable or an ant task, instead?

Maybe the compiling is taking too long so that your PHP script times out?

mmattax
It's not a timeout. He's said it takes 2 seconds to compile it from the command-line.
Vladimir Dyuzhev
when I try compiling with ant i get the same result
Keeth
also when i try compiling with the mxmlc executable i get the same
Keeth
A: 

Exec is always tricky, on any language :-)

Try to:

  • use background execution (add & symbol at the end)
  • use shell_exec instead
  • specify the full path to java executable (may be the one available to PHP is not the one you need?)
  • run a simple HelloWorld java app to see if the problem is in Java or in mxmlc specifically

It's strange that java takes 100% CPU. I cannot explain it with any common mistake made when using exec()... try to send it a SIGQUIT to dump the threads, then read the dump -- may be you'll figure something out.

Vladimir Dyuzhev
+1  A: 

Turns out it was a bug specific to the PHP stack MAMP (http://www.mamp.info/).

Turns out any invocation of the JVM following fails under MAMP, e.g.:

exec('java -version');

The fix is to prefix the command with

export DYLD_LIBRARY_PATH="";

Also I realized there's no reason to use that method of invoking mxmlc.

So here's the final, working command:

exec('export DYLD_LIBRARY_PATH=""; mxmlc MyAS3App.as -default-size 360 280 -output MyAS3App.swf');
Keeth
Wow, this saved my day! Thanks!
thSoft
A: 

i have a prblem same as yours and i can not have query to cmd more than 5 or 6 even for :<?php exec("dir"); ?>

i am add "export DYLD_LIBRARY_PATH="";" to my command but it's not worked, it's important i use WAMP And LAMP .

if you can please help me because this is so important for my project to covert files. thanks

dashtebash
A: 

Hi Keeth, I tried following the way you explained above using export exec('export DYLD_LIBRARY_PATH=""; mxmlc testing.as -default-size 728 90 -output testing.swf');

But still its not working for me. I'm using wamp and path for my as file in wamp is C:/wamp/www/abb/

Am i approaching the wrong way? Please let me know if you know the solution of this.

Thanks

Guest