dpi10335 2017-07-17 17:37
浏览 83

SVN提交命令行与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...

  • 写回答

1条回答 默认 最新

  • doushenmao9036 2017-07-17 18:16
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100