简体   繁体   中英

SVN commit command line with path inside a variable in php

I need to create a web app which works with SVN command line. So I want to use a exec command with svn commit and a variable contains the path of the working copy. I tried this code but didn't work. Commit didn't take place.

<?php
$lpath="c:\a\svn\projectwc";
$msg="first commit";
exec("svn commit -m $msg $lpath");
?>

And yeah I added all the files inside already. I tried by replacing the lpath with path value and it worked. Please help...

Your string expands to

svn commit -m first commit c:\a\svn\projectwc

Whereas you need to do

svn commit -m "first commit" c:\a\svn\projectwc

As the log message is more than one word it needs to be in quotes.

I think you should re-think what you are trying to achieve here. Constructing strings based on user input and passing them to exec is a very bad idea from a security perspective.

Also you tagged the post tortoise-svn - if you invoke TSVN from the command line it pops up the GUI which is definitely not appropriate server side.

Then you've got other considerations like:

  • How to log error messages when things go wrong
  • Does the Web server have sufficient access to the working copy to perform these operations
  • Is the invocation of "svn" even possible in your environment.

Whatever you are trying to do, it's probable there is some free software out there that does it already. svn has a webdav interface and an API implemented in many languages - this would be far safer than using exec

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM