Forum Moderators: coopster

Message Too Old, No Replies

php and subversion, svnlook behaves strangely

php, subversion

         

hanglide

1:25 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



Hello,

When I run svnlook from a php script, the pipe is empty. With the following code (when called from a browser) I can pipe it to a file but all it does is create an empty file.

$cmdstr = "svnlook tree /usr/local/svn/manuals > pipetest.txt";
$fp = popen( $cmdstr, "r" ); // open the output of command as a pipe
while( $buffer = fgetss ( $fp, 4096 ) ) {
echo "$buffer<br>";
echo"loop";
}

The odd thing is, I can log in as apache and run this script from the command line with no problem and I would have thought if it were a permission issue or something like that then it shouldn't have created the file?

If I remove the pipe to the file, it returns nothing. If I change $cmdstr to do a "find /usr/local/......" it works great whether I echo it back or write to a file.

Any thoughts? Resources?

Thanks,

Scott

coopster

4:03 pm on Aug 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Well it certainly does sound like a permissions issue, I agree with you there. Anything showing up in your error logs?

hanglide

5:11 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



Sorry, I should have thought of looking at that before I posted -I'm new to apache/php/linux/webdev and I've been spoiled by the IDE's for C w/debuggers/autocomplete etc... the last few years.

I used phpinfo() to find out where apache had been installed and then found error_log with a recent timestamp. The message that appears to relate to this is:

"svn: Expected version '2' of repository; found version '3'"

I wonder why it generates an error here but not from the command line? Is this just that Apache is more sensitive to an error message being returned and cancels the process?

Is there a way to suppress it? -like with a big stick? I've been searching for hours and a little release would feel pretty good right about now...

Thanks

Scott

coopster

6:01 pm on Aug 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Scripts will typically continue if the errors are NOTICE or WARNING errors, but stop if they are FATAL errors or if the script tells it to stop. Have a look at error_reporting() [php.net], it's associated configuration directive [php.net] and also PHP's error control operators [php.net].

hanglide

8:49 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



Thanks Coopster,

Turned out that an older version of svn had been installed on that machine at sometime in the past. I ran "which svnlook" and realized that it was running the wrong one. Apparently -according to a co-worker- it runs in a different enviroment when run from within a web page as opposed to running the same php file from the command line (even though logged in as "apache")?

For the time being it runs fine as long as I explicitly include the path to the newer version of svnlook.

Thanks again,

Scott

coopster

9:25 pm on Aug 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Glad you nailed it -- have a great weekend.