[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: perl backticks do not capture output (post-commit hook)

From: allan juul <allan_at_muly.dk>
Date: 2006-01-17 21:52:18 CET

Oliver Menge wrote:
> Hello!
>
> Maybe this is not a real subversion question but I am learning too
> many things at the same time. Though it maybe a perl issue I hope to
> get some help here. I have a problem writing a post-commit script in
> perl on a W2K server (perl as a means to overcome the cmd-limitations
> of Windows). However I am neither a windows nor a perl or subversion
> expert.
>
> My perl script (post-commit) fails to capture the output of a
> backtick-call to svnlook, but only when invoked by subversion. When I
> forge the svn call from the command line the scrpt works fine.
>
> I reduced the complexity to make myself clear:
>
> The repository resides in c:/joe/svnrepositories/svn.
> Subversion resides in c:/Programme/subversion
>
> !-------------------------------------------------------------------------
> ! C:\>type c:\joe\svnrepositories\joe\hooks\post-commit.cmd
> ! c:\perl\bin\perl -Ic:\joe\perlscripts c:\joe\perlscripts\post-commit.pl %1 %2
> ! C:\>
> ! --------------------------------------------------------------------------
> ! C:\>type c:\joe\perlscripts\post-commit.pl
> ! #!/usr/bin/perl
> !
> ! $reppath = $ARGV[0];
> ! $revision = $ARGV[1];
> !
> ! #`echo hook output $reppath $revision > c:\\log.txt`;
> ! #`c:/Programme/subversion/bin/svnlook.exe -r $revision changed $reppath >> c:/log.txt`;
> ! # exit;
> !
> ! @svnlook_output = `c:/Programme/subversion/bin/svnlook.exe -r $revision changed $reppath`;
> ! open(HLOG, ">C:/log.txt");
> ! print HLOG "hook output $reppath $revision\n";
> ! print HLOG @svnlook_output;
> ! close(HLOG);
> !
> ! C:\>
> --------------------------------------------------------------------------

it might be the environment is gone in the script.

what happens if you chdir to the executing dir:

# in your bat/cmd file:
c:
cd c:\joe\perlscripts
start c:\perl\bin\perl.exe c:\joe\perlscripts\post-commit.pl %1 %2

also you might want to use this form of executing instead of backsticks.
this might be a help when encountering funny characters in filenames

local *SVNLOOK;
open(SVNLOOK, '-|:utf8', $cmd) || die("$!, cmd: $cmd");
my @svnlook_output = <SVNLOOK>;
close SVNLOOK;

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Jan 18 00:13:13 2006

This is an archived mail posted to the Subversion Users mailing list.