1

I'm on a RedHat server, with a simple PHP page that has a form, with inputs for name, phone, and url.

When the form is submitted, I run a command to compile a swf using mxmlc. The command is this :

$generate_command1 = "export _JAVA_OPTIONS=\"-Xms32m -Xmx64m\"; /opt/flex/bin/mxmlc -define+=NAMES::Name,\"\'$name\'\" -define+=NAMES::Phone,\"\'$phone\'\" -define+=NAMES::Website,\"\'$url\'\" -output /path/to/my/webserver/httpdocs/swfbuilder/generated.swf DynamicTextTest.as";

$last_line = exec($generate_command1, $out);
print_r($last_line);

The result is always :

Loading configuration file /opt/flex/frameworks/flex-config.xml

When I run the same command from ssh into the server, I actually get a swf generated. I.e.

Picked up _JAVA_OPTIONS: -Xms32m -Xmx64m
Loading configuration file /opt/flex/frameworks/flex-config.xml
/var/www/vhosts/tag.domandtom.com/httpdocs/swfbuilder/generated.swf (945 bytes)
[root@htmlfive swfbuilder]# 

Both directory and files have been CHOWN'd for ownership and CHMOD'd for 775... So what am I doing wrong to get this to work from the web page? Should I have a forked process and wait until it's complete? Sleep?

EDIT:

I've looked into fcsh and other mxmlc / java related questions.

7
  • Can I ask, what's the point of compiling your code over and over again on submitting the form? Commented Aug 1, 2011 at 23:14
  • It's a prototype, but essentially, the user is able to input those values, and dynamically generate a swf he or she can download. Additionally, they're able to preview that swf with those values. It's for flash banner ads, and I'm working on a system to make a part of the process more efficient. Does that make sense? Commented Aug 2, 2011 at 3:01
  • 1
    No, it doesn't. Why don't you just compile a swf that takes data as input and generates something for the user to view. Your way of doing it is extremely inefficient, uses resources and doesn't add much (if any) value. Plus, it'll a lot harder to debug. Commented Aug 2, 2011 at 3:04
  • 2
    The user is a buyer for flash ads. They need a collection of swfs, one for every car dealer, location, and link-out to that dealer's website. Instead of creating a single swf, that takes this data in dynamically (as originally proposed), they would like 100+ swfs. Instead of having a developer hand-compile these with the proper values, the user would like to go in and make the swfs themselves within our custom CMS for ad management (in case they add a new dealer on their list.) I understand the technical inefficiences. If you understand the requirements, could you help me solve the problem? Commented Aug 2, 2011 at 16:14
  • Probably a stupid question, but have you checked the obvious things like the PHP script execution limit? Commented Aug 8, 2011 at 19:51

1 Answer 1

2

In re-reviewing the code, I noticed that I shouldn't have escaped the single-quotes. They're valid for the actual execution and I should only escape DOUBLE quotes for php in this instance...

The final code looks like this (for future reference) :

<?php 
$name = "generated";
$phone = "";
$url = "";

if(isset($_POST['name'])) {
    $name = $_POST['name'];
}
if(isset($_POST['phone'])) {
    $phone = $_POST['phone'];
}
if(isset($_POST['url'])) {
    $url = $_POST['url'];
}

$swfname = $name . ".swf";

$generate_command1 = "export _JAVA_OPTIONS=\"-Xms32m -Xmx64m\"; /opt/flex/bin/mxmlc -define+=NAMES::Name,\"'$name'\" -define+=NAMES::Phone,\"'$phone'\" -define+=NAMES::Website,\"'$url'\" -output /path/to/my/webserver/httpdocs/swfbuilder/$swfname DynamicTextTest.as";

exec($generate_command1, $out);
?>
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.