On 2/1/2011 10:54 PM, Waseem Bokhari wrote:



From: David Chapman [mailto:dcchapman@acm.org]
Sent: Wednesday, February 02, 2011 11:48 AM
To: Waseem Bokhari
Cc: users@subversion.apache.org
Subject: Re: Error on Post Commit Hook.BAT


On 2/1/2011 10:16 PM, Waseem Bokhari wrote:

Here is a Post-Commit.bat for generating email on every-commit.


@echo off



::: ARGUMENTS :::::::::::::::::::::::::::::::::::::::






::: GENERAL INFO ::::::::::::::::::::::::::::::::::::

SET DIR=E:\Repositories\WSBokhari\hooks

SET MESSAGE_FILE=%DIR%/message.txt



::: SVN INFO ::::::::::::::::::::::::::::::::::::::::

SET DIR=E:\Repositories\WSBokhari\hooks

SET REPO_PATH=file:///E:/Repositories/WSBokhari


::: Get the author ::::::::::::::::::::::::::::::::::

For /F "Tokens=*" %%I in ('svnlook author %REPOS% -r %REV%') Do Set author=%%I


::: Get the log messsage ::::::::::::::::::::::::::::::::::

For /F "Tokens=*" %%I in ('svnlook log %REPOS% -r %REV%') Do Set log=%%I


::: Set the message body ::::::::::::::::::::::::::::::::::

ECHO Commit - rev %REV% (#%author%): '%log%' - %REPOS% > %MESSAGE_FILE%



::: EMAIL INFO ::::::::::::::::::::::::::::::::::::::


set to=-to ntpk.scm@netsolpk.com


set subj=-s "SVN Commit (Revision %REV%)"


set server=-server mail.netsolpk.com


set auth=-u waseem.bokhari@netsolpk.com –pw 123


set from=-f waseem.bokhari@netsolpk.com



::: SEND THE EMAIL ::::::::::::::::::::::::::::::::::


E:/Repositories/WSBokhari/%MESSAGE_FILE% %server% %to% %from% %subj% %auth%



Error Message:


post-commit hook failed (exit code 1) with output:

The filename, directory name, or volume label syntax is incorrect.





Even file message.txt is being creating in my Hooks Folder according to this::


 SET MESSAGE_FILE=%DIR%/message.txt



This line looks wrong.  Try using a backslash ('\') instead of a forward slash ('/').  Although many Windows programs tolerate forward slashes in file names, the Windows batch processor is not one of them.  It uses forward slashes to mark parameters (as is shown in the "For /F" lines) so it is trying to interpret "/message.txt" as a parameter, not part of your message file name.

If you're going to be creating or editing Windows batch files, I strongly encourage you to buy a book on how to create them.  It's been so long that I can't recommend one to you, unfortunately.

    David Chapman         dcchapman@acm.org
    Chapman Consulting -- San Jose, CA


>Even I have changed the slashed but the message was same.


>Please advice.


Did you change both lines?  I also see forward slashes in the line which is described as "SEND THE EMAIL" at the very end.

For that matter, this line looks wrong too.  Earlier, you set the variable DIR to "E:\Repositories\WSBokhari\hooks".  The value of this variable will be substituted whenever "%DIR%" appears.  Thus if you have "SET MESSAGE_FILE=%DIR%\message.txt" this is the same as "SET MESSAGE_FILE=E:\Repositories\WSBokhari\hooks\message.txt" and the value of this variable will be substituted whenever "%MESSAGE_FILE%" appears, as it does on the last line.

If you replace the forward slashes in the last line with backslashes and perform the substitution of "%MESSAGE_FILE%", the first word of the line will become "E:\Repositories\WSBokhari\E:\Repositories\WSBokhari\hooks\message.txt", which is obviously an invalid Windows path name.

The message file is clearly not intended to include the name of the mail program, so you need to supply the name of the E-mail program.  I don't know what that would be.  Nor do I know the command-line parameters for the E-mail program, so I cannot tell you whether the syntax of this line is correct.  But if your E-mail send program is "E:\Repositories\WSBokhari\hooks\send_message.exe" and it accepted the parameters you have listed, the last line of the batch program would be:

E:\Repositories\WSBokhari\hooks\send_message.exe %MESSAGE_FILE% %server% %to% %from% %subj% %auth%

You really need a book on Windows batch file processing.
    David Chapman         dcchapman@acm.org
    Chapman Consulting -- San Jose, CA