Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:32:21+00:00 2026-06-11T15:32:21+00:00

I’m trying pre-revprop-change hook script on a Windows machine, but find a tough problem.

  • 0

I’m trying pre-revprop-change hook script on a Windows machine, but find a tough problem.

I distill my problem to the following scenario:

I have C:\csvn\data\repositories\tr1\hooks\pre-revprop-change.bat with content:

D:\svntest\testhook.py %*
exit %ERRORLEVEL%

testhook.py is:

import os, sys

if __name__ == '__main__':
    # sys.stderr.write(sys.version+'\n') # this is OK, tried.
    newtext = sys.stdin.read() # try to read new log message

    sys.stderr.write('newtext is: %s\n'%newtext)

    exit(2)

However, when doing a client-side svn propset svn:log --revprop -r 2 "newtext" , I got python error:

Traceback (most recent call last):
  File "D:\svntest\testhook.py", line 5, in <module>
    newtext = sys.stdin.read() # try to read new log message
IOError: [Errno 9] Bad file descriptor

What’s the cause of this error?

It seems that pre-revprop-change.bat does not pass STDIN handle to the py script. Yes, I verified that pre-revprop-change.bat can fetch text from STDIN(according to instructions in Read stdin stream in a batch file).

I also tried to run pre-revprop-change.bat directly from command line, sys.stdin.read() is OK.

Please kindly help me out.

Screen shot below:

enter image description here

Env:

  • Windows Server 2003
  • Collabnet Subversion Edge 2.3(svn 1.7.3 and Apache 2.2.22)
  • Install Python 2.7.1 msi from python.org

===============[LATEST UPDATE]======================

I’m sorry to say: I should have written in the .bat

exit %ERRORLEVEL%

instead of

exit /b %ERRORLEVEL%

For someone who have tried it with me, please fix it and try again. The /b seems to have pre-revprop-change.bat always exit with 0. TIP: Without /b, running the .bat directly from a cmd window will cause the cmd window to close, so we’d better try it with cmd /c "pre-revprop-change.bat some param".

Quick way to reproduce this problem below

What’s more, for those who is still interested, please

  • download this file package http://down.nlscan.com/misc/chjsvnpyhook.zip ,
  • extract them to D:\ ,
  • cd into D:\svntest\tr1_local ,
  • run elog.bat (svn propset svn:log --revprop -r 2 "newtext")

then my problem will be reproduced. (Requirement: svn.exe 1.7 command line(whether collabnet or TortoiseSVN), and Python 2.7 installed)

If you still cannot reproduce the error. I’ve prepared a VMware virtual machine that exhibits the problem exactly. Download the VM at http://down.nlscan.com/misc/chj/winxp-svnhook-py-stdin-error.7z (link expected to be valid until Sep 2013). VMware Player 3.0(free) is sufficient to run that VM.

===============[WORKAROUND FOUND]===================

Very nice workaround provided by @nmenezes, with c:\Python27\python.exe D:\svntest\testhook.py %* in bat .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:32:22+00:00Added an answer on June 11, 2026 at 3:32 pm

    SVN is executing the script without an associated console.
    So you won’t see anything displayed on STDOUT.
    Everything sent to STDERR is displayed as a message on SVN, if the script returns an error code different of 0.

    This kind of script should run unattended, it is independent of input or output from the user.

    You can try to pass the property value as an extra command line parameter.
    To do so, change your .bat to:

    @echo off
    set /p NEWTEXT=
    test.py %* %NEWTEXT%
    exit /b %ERRORLEVEL%
    

    And the .py to:

    import os, sys
    
    if __name__ == '__main__':   
        newtext = sys.argv[6]
        sys.stderr.write('newtext is: %s\n'% newtext)
        exit(2)
    

    I read the batch STDIN to NEWTEXT variable and I pass it to your script as an extra command line parameter.

    This solution does not work for multiple lines values. So, I tried again your original solutions and it worked fine.

    svn propset svn:log --revprop -r 3 -F svn.txt
    

    In this case, the property value is read from the svn.txt file, a text file with multiple lines. In this case, the option with set /p does not work, as we discussed in the comments. But the original script works.

    For information, 5 properties are passed on the command line:

    1 – repository

    2 – revision number

    3 – user

    4 – property name

    5 – operation (M in this case)

    The property value is passed on the stdin of the batch script.

    @Chen, I finally downloaded the image. The problem is solved when you change the hook batch to:

    c:\python27\python.exe d:\svntest\testhook.py %*
    exit %ERRORLEVEL%
    

    It looks that the way your XP machine executes python directly is misconfigured.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.