Reputation: 15
Our university has free hosting on a Linux server, in which I have checked out a SVN project into my local student directory. While remotely logging into the server, I have no problems adding/committing/etc to my SVN project sandbox on the server.
I have a PHP script on the same server that makes a passthru call to perform a simple SVN version number command on that sandbox:
<?php
echo passthru(' 2>&1 cd /nav/to/svnSandbox && 2>&1 svn --version ');
?>
The above exec() call fails server-side and outputs
"sh: 1: svn: not found" to the client side. This implies that SVN isn't installed? However, it is in fact installed on the server, moreover I can use SVN just fine while I'm logged in.
The following PHP code works correctly:
<?php
echo passthru('pwd');
?>
User permissions for the PHP script and the SVN sandbox directory are 755 (I've tried many other variations as well). I have also read this link, among many others.
Is a PHP script not granted certain access to server-side SVN commands?
Why can't I make successful SVN exec() calls from my script? Is there an easier way than my code above?
Do server-admins usually have some sort of safeguard on scripts using exec() that I don't know about?
Upvotes: 0
Views: 851
Reputation: 881123
This implies that SVN isn't installed?
No, it simply implies that svn
cannot be found in your path.
That may be because it's not installed or it may be that your path simply isn't set up correctly for the method you're using.
Compare the output of:
<?php
echo passthru('echo $PATH');
?>
and executing echo $PATH
when logged in to the box.
You'll probably find the svn
directory on the latter but not the former.
Then it'll be a matter of figuring out how to set the path for the passthru method.
That may be as simple as something like:
<?php
echo passthru('( cd /nav/to/svnSandbox; PATH=$PATH:/svnpath; svn --version ) 2>&1');
?>
or:
<?php
echo passthru('( cd /nav/to/svnSandbox; /svnpath/svn --version ) 2>&1');
?>
Upvotes: 1