PHP Write UltraEdit Plug-in script implementation method _php instance

Source: Internet
Author: User
Tags install php php write sprintf svn pscp ultraedit
Demand:

1 SVN code on the local (editor UltraEdit) has a set of, in the development machine (CentOS) a set of local code to be modified to upload to the development machine

2 is not modified and used directly on the development machine because there are many people using the same developer, in order to keep the local backup

idea:

1 Write a script as a UltraEdit plug-in, so that the code changes after the press to create a button to directly save the code locally uploaded to the CentOS

2 Local is Windows, remote is Linux, File Upload tool can use Pscp.exe, scripting language using PHP or Python

3 Local must install PHP, do not need to install the database and Apache

4 in PHP in a process call Pscp.exe, parse the path and so on logic in PHP


steps:

1 ultaedit script in tool configuration

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

The following%p%n%e is the absolute path of the current edit file, passed as a parameter into the synv142.php

2 sync142.php Code
Copy Code code as follows:

<?php
Plugin, sync windwos files to 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", $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 Place Pscp.exe in the sync142 sibling directory
4 the key CTRL + 1 map to this script
So when you write the program, just press CTRL + 1 to replace the current script with the remote script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.