Reputation: 345
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.
Upvotes: 2
Views: 1180
Reputation: 5069
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";
}
Upvotes: 1