tags:

views:

99

answers:

1

Hi,

I'm writing some functions in php using exec() to interrogate a svn.

The commands exec("svn list ".$myurl) works.

Now, I try to get a path on a svn repository with the checkout command. When I put the command "svn checkout http://core.wordress.org/tags/2.9.2/ last-version" directly in the console, it works.

But when I do this from a php script using exec(), like this :

exec("svn checkout ".$myurl, $dir)

it doesn't work.

Have you an idea ??

A: 

This can have a variety of reasons.

  • The user PHP runs under is not allowed to write into the directory you want to check out into

  • The SVN repository requires login credentials that are not cached for the user PHP runs under

  • The SVN checkout process starts, but requires some additional input like the dreaded "Do you want to accept this certificate" with unsigned certificates.

Try adding 2>&1 to the command to redirect stderr to stdout, and take a look at $dir. Also make use of the $return_var parameter to exec().

And as Jacob pointed out, always use escapeshellargs() for your command arguments.

Pekka
Thanks for answers.I think that PHP user is not allowed to write into a directory.You know how to fix it ??
bahamut100
@bahamut if you have access to the server, you can change the directory permissions. If not, you can try to do a `chmod 777` on the directory in your FTP client - just note that this makes the directory writable for everybody on the server.
Pekka
I have access to server via SSH.However : What is the directory to change ????
bahamut100
`chmod 777 your/directory/that/you/want/to/do/the/checkout/in`
Pekka