6

I am trying to run a command using shell_exec but its not returning any output. When I copy the command into command prompt it works like a charm.

Here is the command I'm trying to run.

$result = shell_exec('android update project -p "C:\xampp\htdocs\appBuilder" -t 1');

$result is returning an empty string. When I run the command in command prompt, it shows a message saying the build.xml file was generated successfully. It should be showing the success message in $result.

If I run just the command android update project -p "C:\xampp\htdocs\appBuilder" -t 1 in command prompt, it works.

FYI: This command is to generate a build.xml file for an android application. I'm also running this on a local web server using xampp.

Anyone know what I'm doing wrong?

3
  • What exactly is happening, or not happening? What do you expect?
    – Charles
    Commented Dec 9, 2012 at 1:07
  • could this be a simple path problem? where do you run the command while in command prompt? and have you tried running the same command from a diferent location? Commented Dec 9, 2012 at 1:52
  • After bumping my head around here and there, I re-started by computer and it worked :) Who knew? :) Commented Dec 9, 2012 at 16:12

1 Answer 1

3

A double backslash \\ should be used to print a single \ character (first \ is used to escape the second \):

$result = shell_exec('android update project -p "C:\\xampp\\htdocs\\appBuilder" -t 1');

Also make sure PHP SAFE MODE is set to OFF.

Not the answer you're looking for? Browse other questions tagged or ask your own question.