开发者

How to get svn revision number using exec() and command in PHP?

I need svn revision number from PHP script. I have used the following commands with exec(). But it does not return any thing.

$value = exec("usr/bin/svn --username myusername--password mypassword info /home/mysite/mysite_www/mysite |grep Revision: 开发者_高级运维|cut -c11-", $output, $status); 

or

$value = exec("svn info |grep Revision: |cut -c11-", $output, $status);

I have also tried using share script but no result. Please guide me how to get a SVN revision number using PHP and the command.


I would recommend getting the SVN revision number from the .svn/entries file using something like the following code snippet.

// open .svn/entries file
$content = file_get_contents("/path/to/your/site/.svn/entries");

// get revision number
$lines = explode("\n", $content, 12);
$revision = intval($lines[10]);

// print out the revision number
echo "Revision: " . $revision;

Using this, you could also get the date by parsing the content of $lines[11]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜