How to respond to password prompts with exec()
I know the title of the question is a bit odd. But I don't know what the thing I am trying to do, is called. So, here it goes --
I'm working on a simple ADOBE AIR app generator,
After generating all the necessary files and signing the application using the file adt
I'm supposed to - generate the actual .air
file. Which, after supplying all the parameters asks for password.
How am I supposed to do this? Help!
Packaging an AIR installation file using the AIR Developer Tool (ADT)
PS - If ther's some word to describe what I am doing, please comment :D
[UPDATE]
If one puts
adt -package -storetype pkcs12 -keystore sampleCert.pfx HelloWorld.air
HelloWorld-app.xml HelloWorld.html AIRAliases.js
in t开发者_如何转开发he command line, it prompts for a password. One can enter it -- when using console.
How are you supposed to provide it when you are doing php exec();
?
Apparently, you can specify the password on the command line. Look at their docs and do a find on -storepass
and -keypass
.
-storepass password1 —The password required to access the keystore. If not specified, ADT prompts for the password.
-keypass password2 —The password required to access the private key that is used to sign the AIR application. If not specified, ADT prompts for the password.
You can build the command needed like this:
<?php
$command = "/path/to/adt -package -storetype pkcs12 -storepass password -keypass password -keystore /path/to/sampleCert.pfx /path/to/HelloWorld.air /path/to/HelloWorld-app.xml /path/to/HelloWorld.html /path/to/AIRAliases.js";
$output = exec($command);
?>
Make sure that you include paths to the adt
binary as well as the files needed for the build.
I think you will need to use proc_open instead of exec: http://us3.php.net/manual/en/function.proc-open.php Based off the example there you would do something like this:
$adt_command = "adt -package -storetype pkcs12 -keystore sampleCert.pfx HelloWorld.air HelloWorld-app.xml HelloWorld.html AIRAliases.js";
$password = "keystore_password";
$process = proc_open($adt_command, $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
fwrite($pipes[0], $password);
fclose($pipes[0]);
$return_value = proc_close($process);
}
If I understand you correctly you want to call the ADP
via PHPs exec()
?
In order to control input and output from a commandline tool like ADP you might have a look into the proc_open
-functions, with this you can handle input, output and error pipes.
More information about those can be obtained here in the PHP manual.
精彩评论