PHP寫UltraEdit外掛程式指令碼實現方法

來源:互聯網
上載者:User

需求:

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

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

思路:

1 寫一個指令碼作為UltraEdit的外掛程式,使得代碼修改後按下制定按鍵就能直接將代碼本地儲存後上傳到centos上

2 本地是windows,遠程是linux,檔案上傳工具可以使用pscp.exe,指令碼語言使用PHP或者Python

3 本地必須安裝PHP,不需要安裝資料庫和apache

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

步驟:

1 UltaEdit中在工具配置中設定好指令碼

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

後面的%p%n%e是當前編輯檔案的絕對路徑,作為參數傳入synv142.php中

2 sync142.php代碼
複製代碼 代碼如下:<?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同級目錄下 4 將按鍵Ctrl + 1 映射到這個指令碼於是在編寫程式的時候只要按下Ctrl + 1就可以將當前指令碼替換遠程指令碼

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.