欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP寫UltraEdit插件腳本實現(xiàn)方法

 更新時間:2011年12月26日 21:48:46   作者:  
PHP寫UltraEdit插件腳本實現(xiàn)方法,需要的朋友可以從參考下。
需求:

1 svn上的代碼在本地(編輯器UltraEdit)有一套,在開發(fā)機(centos)上有一套,需要本地的代碼修改以后上傳到開發(fā)機上

2 不直接在開發(fā)機上修改和使用,原因是有多個人都使用同一個開發(fā)機,為了保留本地備份

思路:

1 寫一個腳本作為UltraEdit的插件,使得代碼修改后按下制定按鍵就能直接將代碼本地保存后上傳到centos上

2 本地是windows,遠程是linux,文件上傳工具可以使用pscp.exe,腳本語言使用PHP或者Python

3 本地必須安裝PHP,不需要安裝數(shù)據(jù)庫和apache

4 在PHP中起一個進程調(diào)用pscp.exe, 解析路徑等邏輯放在php中


步驟:

1 UltaEdit中在工具配置中設(shè)定好腳本

php "C:\Users\nickyjf\Desktop\mesh\Tools\syncFile\sync142.php" %p%n%e

后面的%p%n%e是當前編輯文件的絕對路徑,作為參數(shù)傳入synv142.php中

image

2 sync142.php代碼
復(fù)制代碼 代碼如下:

<?php
//插件,將windwos文件同步到linux上
//php "rsync142.php" %p%n%e
//valid argv
//testCode
/*
$argv = array(
"rsync142.php",
"E:\\SVN\\test\\www\\include\\ggg\\test\\DTest.php",
);
*/
if(count($argv) == 2)
{
$sFilePath = $argv[1];
$sServerName = "192.168.10.142";
$sServerUserName = "name";
$sServerPassword = "password";
$sServerPath = sGetServerPath($sFilePath);
$realPath = sprintf("%s@%s:/%s", $sServerUserName, $sServerName, $sServerPath);
try
{
$cmd = sprintf("pscp.exe -pw %s %s %s", $sServerPassword, $sFilePath, $realPath);
echo $cmd."\n";
system($cmd);
}
catch(Exception $e)
{
print_r($e);exit;
}
}
function sGetServerPath($sWindowsPath)
{
$ret = "";
$paths = explode("\\", $sWindowsPath);
if($startKey = array_search("www", $paths))
{
$ret = "test/";
for($i=$startKey+1; $i<count($paths); $i++)
{
$ret .= $paths[$i] . "/";
}
$ret = trim($ret, "/");
}
return $ret;
}
?>

3 將pscp.exe放在sync142同級目錄下
image
 
4 將按鍵Ctrl + 1 映射到這個腳本
于是在編寫程序的時候只要按下Ctrl + 1就可以將當前腳本替換遠程腳本

相關(guān)文章

最新評論