[英]SVN Pre-Commit Hook in Perl on Windows
I was writing Perl script to do SVN pre-commit check on Windows machine, and I use VisualSVN Server. 我正在编写Perl脚本以在Windows计算机上进行SVN预提交检查,并且我使用VisualSVN Server。
Here is the code: 这是代码:
pre-commit.bat 预commit.bat
C:\Perl\bin\perl.exe D:\Repositories\iCP\hooks\pre-commit.pl %1 %2
exit %ERRORLEVEL%
pre-commit.pl pre-commit.pl
#!/usr/bin/perl
use strict;
use warnings;
my $repos = $ARGV[0];
my $txn = $ARGV[1];
my $svnlook = "D:\\svnlook.exe";
my $hooks = "D:\\Repositories\\iCP\\hooks";
if(system("$svnlook log -t $txn $repos >$hooks\\res.txt"))
{
die "Unable to finish system(): $!\n";
}
....
Basically, I want "svnlook log" result to be redirected to res.txt, then I can read from this file. 基本上,我希望将“ svnlook日志”结果重定向到res.txt,然后可以从该文件读取。
But when I do commit from TortoiseSVN, the perl script died with " Unable to finish System(): Inappropriate IO control operation ", I don't know what went wrong. 但是,当我从TortoiseSVN提交时,perl脚本因“ 无法完成System():不适当的IO控制操作 ”而死亡,我不知道出了什么问题。
Thanks for your help in advance. 感谢您的帮助。
Most probable it is a qoute problem. 最有可能是qoute问题。 Perl use \\ as an escape sequnce, so when you include a variable with double \\ it will be converted to simple \\. Perl使用\\作为转义序列,因此当您包含带有double \\的变量时,它将转换为简单\\。
Try this: 尝试这个:
my $svnlook = "D:\\\\svnlook.exe";
my $hooks = "D:\\\\Repositories\\\\iCP\\\\hooks";
if(system("$svnlook log -t $txn $repos >$hooks\\res.txt"))
{
die "Unable to finish system(): $!\n";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.