SVN Pre-Commit Hook in Perl on Windows



我正在编写Perl脚本来在Windows机器上进行SVN预提交检查,我使用VisualSVN服务器。

这是代码:

预提交.bat

C:Perlbinperl.exe D:RepositoriesiCPhookspre-commit.pl %1 %2
exit %ERRORLEVEL%

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";
}
....

基本上,我希望将"svnlook log"结果重定向到 res.txt,然后我可以从这个文件中读取。

但是当我从TortoiseSVN提交时,perl脚本以"无法完成System():不适当的IO控制操作"而死亡,我不知道出了什么问题。

提前感谢您的帮助。

最有可能的是 qoute 问题。Perl 使用 \ 作为转义序列,所以当你包含一个带有双 \ 的变量时,它将被转换为简单 \。

试试这个:

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";
}

最新更新