tags:

views:

1934

answers:

3

I am using this php code:

       exec("unrar e file.rar",$ret,$code);

and getting an error code of illegal command ie 127 ... but when I am using this command through ssh its working ... because unrar is installed on the server ... so can anyone guess why exec is not doing the right stuff?

+4  A: 

Try using the direct path of the application (/usr/bin/unrar of whatever), it sounds like php can't find the application.

Jamie Lewis
I have to agree it sounds like the directory containing the unrar binary is not included in the PATH var so using a direct path should help, or just adding the binary to the directory if the path cannot be found.
Unkwntech
+1  A: 

thanx all for your response!!

I tried this

//somedir is inside the directory where php file is
chdir("somedir");
exec("/home/username/bin/unrar e /home/path/to/dir/file.rar");

and now it returned no exit code ... oher commands are doing file .. i tried mkdir etc .. :s

Intellex
btw this command was running straight on shell
Intellex
A: 

ohkiee guyz thanx ... and yes there might be some errors with $PATH ... but with given full path its working :)

exec("/home/user/bin/unrar e /home/user/xxx/yyy/file.rar");

Intellex