5

I have created an exe file that will print to console the first and second arguments that it receives.

In the SVN post-commit hook I wrote:

PATH_TO_FILE\print.exe "%1" "%2"

when I make a check-in, it gets stuck.

%1 is the PATH
%2 is revision number

EDIT

The answer to my question is that the executable file should be in the "bin" directory of the SVN Server, not in the hooks folder of the repository.

Thank you all, Oded.

Oded
  • 795
  • 2
  • 12
  • 32
  • 1
    @Oded: you added a lot of extra details in the comments to the answers. You can make the question clearer & better by editing it to add the details. – JXG Feb 04 '10 at 08:24

3 Answers3

1

Print takes a filename to put on the printer. You are supplying a directory i assume of your description. Try writing something to a file.

echo "%1" "%2" > c:\temp\log.txt
Peter Lindqvist
  • 10,122
  • 3
  • 41
  • 60
  • I will eventually want to execute a script from an exe file. So I have to get the file running. – Oded Nov 10 '09 at 12:12
  • 1
    I know you do, but try starting out with the easiest possible scenario. – Peter Lindqvist Nov 10 '09 at 12:43
  • I tried what you said. It does creates a txt file. I tried something like: echo "%1" "%2" > c:\log.txt print.exe "%1" "%2" (sending the 2 arguments). and it's still get stuck. the commit doesn't finish. the commit window stays open. – Oded Nov 11 '09 at 07:00
  • So the problem is with print.exe, now is that some program you have created yourself? – Peter Lindqvist Nov 11 '09 at 07:30
  • yes. To be sure, I created a new exe file that simply writes to file (just like your suggestion). and it still gets stuck. – Oded Nov 11 '09 at 07:33
  • that's messed up. i'm afraid i can't help you then. – Peter Lindqvist Nov 11 '09 at 08:36
0

What OS are we talking about? If it's Windows I don't think you should have the quotes (") around the parameters.

What is "PATH_TO_FILE"? And environment variable? What is it's value? Have you checked that it doesn't include a final backslash? Have you restarted after changing the environment variable. Is it a system wide or user level environment variable. Remember that if you are running the SVN server as a service it's under a different user so the env var might not be defined for that user. Why don't you just put the full path in directly for now just to test it's nothing to do with an incorrect environment variable.

You say "it gets stuck" do you get an error? What happens exactly? Some more details of how it fails might help.

If this is Windows you are using, you can redirect any errors to a file by doing this:

PATH_TO_FILE\print.exe %1 %2 > c:\output.txt

Is this a plain SVN server or are you using visualSVN Server?

Simon P Stevens
  • 27,303
  • 5
  • 81
  • 107
  • I'm using VisualSVN Server. running on Windows server. the PATH of the exe file is: D:\print.exe . The commit window doesn't do anything. It doesn't show an error or anything. neither a complete message nor an error one. – Oded Nov 10 '09 at 12:10
  • It almost sounds as if the commit never takes place, that could be the source of your problem. The hook is never executed if the commit never makes it to the repository – Peter Lindqvist Nov 10 '09 at 12:44
  • Yeah, what Peter says is possible. If you remove the hook, does the commit work then? – Simon P Stevens Nov 10 '09 at 12:46
  • if the PATH_TO_FILE is "d:\print.exe" then your command will resolve to "D:\print.exe\print.exe" which is obviously wrong. Check your environment variable. – Simon P Stevens Nov 10 '09 at 12:47
  • if I remove the hook. the commit does take place. the PATH_TO_FILE is not an environment variable. I just wrote it as an example. for our sake of the problem. I put the exe file in D: . therefore its path is d:\print.exe (disregard the file name) – Oded Nov 10 '09 at 13:32
  • @Oded: Ahh, that make sense. Sorry. Have you tried simplifying it like Peter suggests in his answer. Break it down into something really simple and make sure it is running like that first. – Simon P Stevens Nov 10 '09 at 13:43
  • Then i'm afraid i can't help you out. I have too little knowledge of the actual server implementation. – Peter Lindqvist Nov 10 '09 at 16:14
  • Thank you for the help :) If I will come up with something, I will post it. – Oded Nov 11 '09 at 10:37
0

It must be Windows environment since I see print.exe. I simply echo the arguments like below.

echo %1 %2 >&2

This seems to print to the command prompt without issues.

publicRavi
  • 2,657
  • 8
  • 28
  • 34