时间:2021-07-01 10:21:17 帮助过:6人阅读
//插件,将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{
$ret .= $paths[$i] . "/";
}
$ret = trim($ret, "/");
}
return $ret;
}
?>
3 将pscp.exe放在sync142同级目录下 4 将按键Ctrl + 1 映射到这个脚本 于是在编写程序的时候只要按下Ctrl + 1就可以将当前脚本替换远程脚本