Click to See Complete Forum and Search --> : Exec problem


xavikevicious
December 17th, 2004, 05:43 PM
i have one problem with exec function. i want to execute unzip like this:

exec("/usr/bin/unzip Analisi_Programa_Anticopia/Fitxer/fitxerAnticopia.zip -d Analisi_Programa_Anticopia/Fitxer/practiquesComprimides";

in server my working directory is script/ . Inside this there is Analisi_Programa_Anticopia/ directory. if i write these sentence ( unzip Analisi_P........ ) in server's shell the unzip sequence is ok.

which is my problem? is it possible that my server don't accept exec function??have i change anything in my php.ini file?

thanks in advance

xavik

pd-all directories and files have all permissions. My php version is 4.

visualAd
December 17th, 2004, 06:15 PM
What is the error you are getting?

xavikevicious
December 18th, 2004, 04:10 AM
hi!

is there any way for looking at the runtime errors ??

i don't see any error in my screen. my .zip archive doesn't unzipped. Do you undestand me?

xavik

visualAd
December 18th, 2004, 05:32 AM
You can grab the output of the exec command by passing it an extra parameter.


exec("/usr/bin/unzip Analisi_Programa_Anticopia/Fitxer/fitxerAnticopia.zip -d Analisi_Programa_Anticopia/Fitxer/practiquesComprimides", $output);

print_r($output);

xavikevicious
December 18th, 2004, 07:33 AM
hi

print_r($output) give me an "Array()" sollution on my screen.

now im going to look at how i can to pass to string this array.

thanks

xavik

visualAd
December 18th, 2004, 07:42 AM
Print_r will also print the contents of the array. In this case the program did not have any ouptput, therefore, an empty array. Try passing the program absolute paths to the files you want to extract instead of relative.

xavikevicious
December 18th, 2004, 07:43 AM
with an implode function ;)

well, with print_r($output): $output is empty. there aren't any!!

xavik

xavikevicious
December 18th, 2004, 07:52 AM
hi again,

exec("/usr/bin/unzip /users/home/alumnes/TM/tm05609/scripts/Analisi_Programa_Anticopia/Fitxer/fitxerAnticopia.zip -d /users/home/alumnes/TM/tm05609/scripts/Analisi_Programa_Anticopia/Fitxer/practiquesComprimides",$out);

with absolute paths and my $out output is empty too.

do you know anymore else??

xavik

visualAd
December 18th, 2004, 08:04 AM
My guess is that there is an error but it is being sent to the error sream instead of the standard output stream. Try redirecting the error stream to the standard output and see what happens:


/usr/bin/unzip /users/home/alumnes/TM/tm05609/scripts/Analisi_Programa_Anticopia/Fitxer/fitxerAnticopia.zip -d /users/home/alumnes/TM/tm05609/scripts/Analisi_Programa_Anticopia/Fitxer/practiquesComprimides 2>&1

xavikevicious
December 20th, 2004, 04:49 AM
hi again,

my error is:

Array([0] sh: /usr/bin/unzip no such file or directory).

unzip is installed on my server and the same sentence is written for me on command line and the unzip is successful there.

xavik

visualAd
December 21st, 2004, 09:39 AM
I think apache may be chrooted into a particular directory. Are you hosting off your own server or a shared server? You can get around this by finding a directory to which Apache/PHP has access to and copy the unzip program into it, you may also have to copy any shared libraries it uses too.

xavikevicious
December 21st, 2004, 10:49 AM
i have look at my php.ini file and the sentence 'doc_root' has a 'no value' value , my php hasn't got initial directory. Im hosting off a shared server ( its an university server with lots of users ) and i cant to install unzip nowhere because im not an administrator. :(

visualAd
December 21st, 2004, 10:56 AM
Find a directory you know PHP has access to and copy the unzip binary to that directory, you don't need to be an administrator to do that.

xavikevicious
December 21st, 2004, 11:20 AM
thanks for all

visualAd
December 21st, 2004, 11:26 AM
I would be interested to know whether you have solved the problem. :wave:

xavikevicious
December 22nd, 2004, 03:52 AM
Last question:

I have been looking for on net a binary unzip but for Unix there are several versions ( one for each Unix OS). My question is: How i can to know which Unix OS i have in my server?? Is there any command for this??

xavik

AndyTower
December 23rd, 2004, 04:50 AM
Last question:
I have been looking for on net a binary unzip but for Unix there are several versions ( one for each Unix OS). My question is: How i can to know which Unix OS i have in my server?? Is there any command for this??


Maybe phpinfo() help you?
Or you can use getenv() function?
Or you can use _SERVER array?