views:

430

answers:

4

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.

A: 

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
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
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
Yeah, what Peter says is possible. If you remove the hook, does the commit work then?
Simon P Stevens
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
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
@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
Then i'm afraid i can't help you out. I have too little knowledge of the actual server implementation.
Peter Lindqvist
Thank you for the help :)If I will come up with something, I will post it.
Oded
+1  A: 

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
I will eventually want to execute a script from an exe file. So I have to get the file running.
Oded
I know you do, but try starting out with the easiest possible scenario.
Peter Lindqvist
I tried what you said. It does creates a txt file. I tried something like:echo "%1" "%2" > c:\log.txtprint.exe "%1" "%2" (sending the 2 arguments).and it's still get stuck. the commit doesn't finish. the commit window stays open.
Oded
So the problem is with print.exe, now is that some program you have created yourself?
Peter Lindqvist
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
that's messed up. i'm afraid i can't help you then.
Peter Lindqvist
A: 

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
A: 

I was trying to do the same. I'm using Visual SVN Server + Tortoise subversion client. I wrote hooks in c#.net, vbs, jscript but none of them seems to be executing... its commiting the file and in the tortoise svn commit window, the error i'm getting is post_commit.exe is not recognized as an internal or external command, operable program or batch file. this is the same with js, vbs etc.. Thanks In Advance...

Tried echo "%1" "%2" > c:\temp\log.txt and its giving the correct output...

ajeeshco