2

i'm trying to integrate svn in a php script to automate a website startup and versioning.

I've made some check during the steps of the creation using the exec php command together with the svn and svnadmin command.

so, when i make and hotcopy (of an unexsistant repository) it returns value 1 (and its correct) but svnadmin create (with a path completely absurd) always returns 0 (like if the content was created, but that is not true!)

public function routine($istr, $search, $replace) {
 $output = array();
 $returnvar = 0;
 $istr = str_replace($search,$replace,$istr);
 exec($istr." 2>&1", $output,$returnvar);
 $this->addMessage($istr);
 if($returnvar != 0) {
  $this->addMessage("!!! GOT ERRORS !!!");
  $this->addMessage(implode("\n", $output));
 }
}

This route actually works, but the returnvar is always 0 (if the svnadmin command is different from hotcopy).

The meaning of the function is that i would like to show the complete output only if there is an error. not show anything otherwise (or maybe a confirmation message)

hope soeone can help ty in advance

4
  • not sure if it is your typo, there is a missing " Commented Mar 12, 2013 at 7:47
  • yes it was another typo.. Commented Mar 12, 2013 at 7:54
  • You should take a look at github.com/webcreate/vcs Commented Mar 12, 2013 at 15:49
  • well that is too much.. what we do are simple svn commands.. so i don't think we need such a project to make it work (also i've found the solution myself, and posted as comment, and its alot easier then adding an entire project to my project!) Commented Mar 12, 2013 at 16:20

1 Answer 1

1

Found the solution: http://www.php.net/manual/en/function.system.php#94929

modified it for my purpose and added to my project :) now my routine looks like this:

public function routine($istr, $search="", $replace="") {
    $output = array();
    if($search != "" || $replace != "")
        $istr = str_replace($search,$replace,$istr);
    $output = $this->runExec($istr);
    $this->addMessage(preg_replace("/[\n\r]/","",$istr));
    if(strlen($output['stdout']) > 5)
        $this->addMessage($output['stdout']);

    if($output['return'] != "0") {
        $this->addMessage("<font color='red'>!!! GOT ERRORS !!!");
        $this->addMessage($output['stderr']);
        $this->addMessage("</font>");

        return false;
    } else
        $this->addMessage("<font color='orange'>!!! EXEC SUCCESS !!!</font>");

    return true;
}

and works like a charm :)

Sign up to request clarification or add additional context in comments.

1 Comment

"You can accept your own answer in 2 days" got this message when i try >_<

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.