1

PHP's exec() function is turned off in my hosting server and it's not possible to change it (for security reasons). Are there alternatives for the exec() function?

Here is more info about my problem:

What I want to do: I want to use .jar file in host server.

This is how it looks on my localhost:

function generateReqXML() {
   exec('"C:\Program Files\Java\jdk1.7.0_21\bin\java.exe"
                 -jar vaiisis.jar auth', $out);
 }

This .jar file help my system to generate XML code.

This code work perfect for my local machine, but its facing the problem when I am trying to use it in my host server.

ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
Skyluk
  • 59
  • 3
  • 11
  • 5
    As it should be, what are you trying to do? – Kisaragi Jan 11 '17 at 15:49
  • 1
    If the hosting server does not want you to use any exec-like functionality then doing so via workarounds would be very "naughty" of you. However there may be a build-in PHP function that does what you need, so you can tell us that that is. – apokryfos Jan 11 '17 at 15:50
  • 1
    Specify what you are trying to do and how you have attempted to solve it. We can help from there. – nerdlyist Jan 11 '17 at 17:58
  • 1
    You might find [this answer](http://stackoverflow.com/a/25281280/924299) helpful; it suggests a workflow of `PHP > Python > Java`. Another idea [mentioned here](http://stackoverflow.com/questions/35224251/is-there-any-alternative-for-php-exec-shell-exec-system-passthrough-f) is to execute via a bash script run by cron based on a database value set by PHP. – showdev Jan 11 '17 at 19:56

1 Answers1

0

Alternatives to exec are:

system(); passthru(); shell_exec();

You can check if these are available with echo ini_get("disable_functions");

But since these are probably disabled there are only non-PHP options left.

Do you have to use the exec() function via PHP? You could for example write a shell script, which can be invoked via cron to do your job.

What are you exactly trying to accomplish?

VaLLe.
  • 160
  • 1
  • 6