Jump to content

Unbale to use shell_exec


theface

Recommended Posts

As i haven't used any windows past xp and i dont know which version you have i cant really help.

I personally use linux and for me shell_exec needs a bit more info to work.

Example:

shell_exec("DISPLAY=:0 sudo -u username firefox ".$url);

 

Now i know this will not work for you as your on windows but you should research the function a bit more and try and get some insight into what the function may need/require in order for it to work.

 

On the other hand maybe on windows you don't need to do anything and it's just the command itself thats the problem.

i am not sure whether this can help or not:  but your problem seems to be similar (command working from batch file or command line and not through shell_exec).

 

I found out that in my case some things needed to be set (which normally are set by default).

 

the options -jo

-j means: don't recreate the paths found in the archive

-o means: always overwrite files

 

And I needed to specify the destination path (even though it should unzip in the same directory when not specified), this is done by -d [path]

 

The strange thing was that I didn't have to put these options when I would give the command on the command-line, only when I would call it with shell_exec.

 

So the complete command in php would be for me:

 

shell_exec('unzip -jo /path_to_archive/archive.zip  -d /destination_path')

 

And putting en echo in front will help you a lot.

it should tell you something like this:

   

 

Archive:  /path_to_zip/archive.zip

  inflating: /destination_path/file1.jpeg

  inflating: /destination_path/file2.jpeg

  inflating: /destination_path/file3.jpeg

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.