Corey
Corey

Reputation: 781

shell_exec with PHP

I am attempting to run apktool (just a tool to unpackage android applications) over the web using PHP shell_exec but it isn't working. Does anyone know why this might be?

This is what the line of code actually looks like:

   $output = `apktool d -f $file_name`;

Any suggestions would help I'm totally at a loss why I run the php and nothing happens. Thanks!

Upvotes: 0

Views: 1131

Answers (3)

DraK
DraK

Reputation: 21

I found the solution. Create build.sh file with exec permissions and write there this code:

#!/bin/bash
export PATH=/opt/local/bin:/opt/local/sbin:/usr/bin/:/usr/sbin/:/bin:/sbin/:/bin/sbin:/usr/local/bin:/usr/X11/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

/usr/local/bin/apktool b -d $1 $2

-- usage ./build.sh

<? php shell_exec("/path/to/build.sh $dir $file"); ?>

Upvotes: 2

Anze Jarni
Anze Jarni

Reputation: 1157

check if you web server (probably apache) has sufficient permissions to execute apktool. Include the whole path to the apktool binary. Use single quotes if there are spaces in your file name.

Check your web server's logs if there is any detail why the command is not executed.

Upvotes: 1

brian_d
brian_d

Reputation: 11395

Make sure that your actual line is:

 $output = shell_exec(`apktool d -f $file_name`);

And that your php.ini file does not have safe_mode turned on or have shell_exec listed in the disable_functions directive.

Upvotes: 0

Related Questions