2
votes

I was writing Perl script to do SVN pre-commit check on Windows machine, and I use VisualSVN Server.

Here is the code:

pre-commit.bat

C:\Perl\bin\perl.exe D:\Repositories\iCP\hooks\pre-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";
}

....

Basically, I want "svnlook log" result to be redirected to res.txt, then I can read from this file.

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.

Thanks for your help in advance.

1
Does it work when you omit the output redirect (>$hooks...)?harpun
@harpun when I omit the redirect, it still doesn't work. I think the problem is with the system command, maybe permission, I'm not sure.foolhunger

1 Answers

1
votes

Most probable it is a qoute problem. Perl use \ as an escape sequnce, so when you include a variable with double \ it will be converted to simple \.

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