You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Tom Malia <to...@ttdsinc.com> on 2007/08/15 15:28:38 UTC

Using VBScript for hooks? pre-revprop-change.vbs?

I'm trying to write a pre-revprop-change hook using VBScript (Trying to
implement svnsync)

 

The problem I'm having is, Subversion doesn't appear to be finding the file.

 

If I name the file: pre-revprop-change.vbs

 

And I run svnsync initialize it acts as if the hook script is not there.

 

If I name the file: pre-revprop-change.wsf

 

And I run svnsync initialize it tells me that it "failed to start" the
script file.

 

I assume the issue with wsf is that I don't have the Microsoft component
that actually runs wsf files properly installed/registered.  I'm hoping that
is irrelevant though because I'd rather be able to just use VBS files.

 

Why does it seem like Subversion is not looking for the: VBS version of the
file?

 

Thanks in advance,

Tom Malia

 

p.s. It would be really nice if the standard hooks directory contained a
complete set of VBScript template files for us non-UNIX folks along with the
template Bash scripts.

 

 


Re: Using VBScript for hooks? pre-revprop-change.vbs?

Posted by fj <fj...@effjay.com>.
Tom Malia wrote:
>
> I’m trying to write a pre-revprop-change hook using VBScript (Trying 
> to implement svnsync)
>
> The problem I’m having is, Subversion doesn’t appear to be finding the 
> file.
>
> If I name the file: pre-revprop-change.vbs
>
> And I run svnsync initialize it acts as if the hook script is not there.
>
> If I name the file: pre-revprop-change.wsf
>
> And I run svnsync initialize it tells me that it “failed to start” the 
> script file.
>
> I assume the issue with wsf is that I don’t have the Microsoft 
> component that actually runs wsf files properly installed/registered. 
> I’m hoping that is irrelevant though because I’d rather be able to 
> just use VBS files.
>
> Why does it seem like Subversion is not looking for the: VBS version 
> of the file?
>
> Thanks in advance,
>
> Tom Malia
>
> p.s. It would be really nice if the standard hooks directory contained 
> a complete set of VBScript template files for us non-UNIX folks along 
> with the template Bash scripts.
>
Unfortunately, I cannot give you **the** answer to your 
vbscript-hookscript dilema, but I hope this info will be of use to you 
as you wrestle with life at the ms-dos command line:

1. bash on windows? there's no "bash"-ing on windows unless you replace 
the native/default command interpreter, or run another on top of it, 
such as cygwin. (note -- "bashing on windows" != "bash"-ing on 
windows... both of which I've done at one time or another ;-)

2. puns aside, you may find these two resources helpful in writing any 
sort of scripts to run in the native environments provided by MS Windows:

Rob van der Woude's script / batch file info at: 
http://www.robvanderwoude.com/

for when you really do need to write batch files for cmd.exe, or 
command.com, or if you need to do other MS-related scripting (e.g. 
vbscript).

and,

The GnuWin32 project at http://gnuwin32.sourceforge.net/packages.html

The group behind this effort has ported a large portion of the unix 
utilities over to run natively in MS Windows -- directly on top of 
cmd.exe or command.com. No cygwin or other similar "layer" required.

3. I haven't yet done much with hook scripts in any environment, but I 
have been in situations where I simply had to write batch programs, and 
both these resources were very helpful to me. My largest and most 
complicated ms-dos effort was writing a utility to export a large source 
tree from (old) starteam and to load it into a new SVN server. We were 
trying to keep the target SVN box as pristine as possible(wintel type), 
so I couldn't count on much being there; certainly not cygwin, perl, any 
visual studio or other heavy-weight programming tools, so I wrote it 
entirely in "ms-dos". yech. it was painful, but sometimes you just have 
to suck it up.

The result was nearly "pure" dos batch file (for w2k NT) -- there were a 
few things that just would have been exceedingly painful to try to 
implement with ms-dos' utilities. If I remember correctly, I used 3 
gnuwin32 utilities, and they reduced the redness and irritation 
considerably<grin>. So, if you're stuck having to write batch files, 
there's no reason you cannot enrich the utilities you can call from 
those batch files, i.e. by installing gnuwin32 utilities where they make 
sense.

4. There's actually "reasonable" (for microsoft, anyway) documentation 
on the command line utilities also, but it's not especially obvious to 
find. Just in case you don't know where to get to it in windows, I found 
these pages particularly useful when writing batch files:

Start => Help and Support.
search on these strings WITH the quotes, and bookmark in your Help & 
Support options the pages I've noted from the search results:

string: 'Cmd', bookmark page having that title
string: 'Command shell overview', bookmark page having same title
string: 'Command-line reference A-Z', bookmark page having same title
string: 'Automating command-line tasks', bookmark results page "Using 
command-based scripting tools"


5. And as I cited above, Rob's web site was extremely helpful to me, 
often providing expanded (and more useful, less trivial) examples of the 
(often) arcane ways that microsoft's command interpreters do things we 
would find trivial in, say, bash.

Best of luck.
-fj

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Using VBScript for hooks? pre-revprop-change.vbs?

Posted by Andy Levy <an...@gmail.com>.
On 8/15/07, Tom Malia <to...@ttdsinc.com> wrote:
> Thanks for the response.  So this sounds like a real headache.  I suppose I
> could install Perl on the machine and use Perl scripts but I hate having to
> juggle a dozen different languages if I don't have to.
>
> Do you happen to know if you can write VB6 EXE's that will work as command
> hook programs?  I know that VB6 has the same problem when it comes to the
> fact that it's actually running inside it's own virtual machine so I'm not
> sure if it can properly take command line arguments and return the correct
> exit codes... but if it could that would be a lot easier for me.

VB6 EXEs are real EXEs as far as the shell, etc. are concerned so you
should be fine doing that as long as you can parse the arguments
(which is very doable, I think I did it once a long time ago). The
exit codes shouldn't be a problem either - only issue you might have
is tapping into stderr instead of stdout.

> What about "Bash" on windows?  What would I need to do to be able to run the
> Bash files as they are in windows?  I assume something can be installed to
> allow this?

I think you'd have to run your server in a cygwin environment which
understands that those scripts are executables. On Windows, bash
scripts require an interpreter just like WSH scripts - plus, from what
I recall reading the source, the libraries don't look for the .sh
extension on Windows.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Using VBScript for hooks? pre-revprop-change.vbs?

Posted by Tom Malia <to...@ttdsinc.com>.
Thanks for the response.  So this sounds like a real headache.  I suppose I
could install Perl on the machine and use Perl scripts but I hate having to
juggle a dozen different languages if I don't have to.

Do you happen to know if you can write VB6 EXE's that will work as command
hook programs?  I know that VB6 has the same problem when it comes to the
fact that it's actually running inside it's own virtual machine so I'm not
sure if it can properly take command line arguments and return the correct
exit codes... but if it could that would be a lot easier for me.

What about "Bash" on windows?  What would I need to do to be able to run the
Bash files as they are in windows?  I assume something can be installed to
allow this?

Thanks in advance,
Tom Malia

-----Original Message-----
From: Andy Levy [mailto:andy.levy@gmail.com] 
Sent: Wednesday, August 15, 2007 11:46 AM
To: Tom Malia
Cc: users@subversion.tigris.org
Subject: Re: Using VBScript for hooks? pre-revprop-change.vbs?

On 8/15/07, Tom Malia <to...@ttdsinc.com> wrote:
> I'm trying to write a pre-revprop-change hook using VBScript (Trying to
> implement svnsync)
>
> The problem I'm having is, Subversion doesn't appear to be finding the
file.
>
> If I name the file: pre-revprop-change.vbs
>
> And I run svnsync initialize it acts as if the hook script is not there.
>
> If I name the file: pre-revprop-change.wsf
>
> And I run svnsync initialize it tells me that it "failed to start" the
> script file.
>
> I assume the issue with wsf is that I don't have the Microsoft component
> that actually runs wsf files properly installed/registered.  I'm hoping
that
> is irrelevant though because I'd rather be able to just use VBS files.
>
> Why does it seem like Subversion is not looking for the: VBS version of
the
> file?
>
> p.s. It would be really nice if the standard hooks directory contained a
> complete set of VBScript template files for us non-UNIX folks along with
the
> template Bash scripts.

I went down this path earlier this year. The short version is that VBS
files are not themselves executable as far as Windows is concerned -
they require being run through an interpreter.

The Subversion libraries look for the hook name followed by a "known
executable extension" on Windows - .bat, .exe and .cmd. So you're
right - Subversion isn't looking for the VBS version of the file. I
don't recall the state of WSF support but I'm fairly sure it doesn't
work either for the same reason.

The trouble is that because these scripts require an interpreter, the
library needs to call "path\to\cscript.exe HOOKNAME.vbs|wsf" and that
path to cscript.exe isn't the same on every system, and hook scripts
run with an empty environment so you can't rely upon the one in %PATH%
(because %PATH% is minimal or empty).

You also (to my knowledge) can't pass parameters to "bare" .VBS files,
but you can with WSF. I may be wrong though.

So...as a workaround, you can write a one-line .BAT file which calls
path\to\cscript.exe path\to\hookname.VBS %1 %2 %3 etc. - basically
passing the same parameters into that script which were passed into
the batchfile. I'm not sure how well that'll work with passing
messages back to the client, as I haven't implemented hook scripts in
WSH yet (once I get time away from my primary duties in the office, I
will hopefully be doing so).


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Using VBScript for hooks? pre-revprop-change.vbs?

Posted by Andy Levy <an...@gmail.com>.
On 8/15/07, Tom Malia <to...@ttdsinc.com> wrote:
> I'm trying to write a pre-revprop-change hook using VBScript (Trying to
> implement svnsync)
>
> The problem I'm having is, Subversion doesn't appear to be finding the file.
>
> If I name the file: pre-revprop-change.vbs
>
> And I run svnsync initialize it acts as if the hook script is not there.
>
> If I name the file: pre-revprop-change.wsf
>
> And I run svnsync initialize it tells me that it "failed to start" the
> script file.
>
> I assume the issue with wsf is that I don't have the Microsoft component
> that actually runs wsf files properly installed/registered.  I'm hoping that
> is irrelevant though because I'd rather be able to just use VBS files.
>
> Why does it seem like Subversion is not looking for the: VBS version of the
> file?
>
> p.s. It would be really nice if the standard hooks directory contained a
> complete set of VBScript template files for us non-UNIX folks along with the
> template Bash scripts.

I went down this path earlier this year. The short version is that VBS
files are not themselves executable as far as Windows is concerned -
they require being run through an interpreter.

The Subversion libraries look for the hook name followed by a "known
executable extension" on Windows - .bat, .exe and .cmd. So you're
right - Subversion isn't looking for the VBS version of the file. I
don't recall the state of WSF support but I'm fairly sure it doesn't
work either for the same reason.

The trouble is that because these scripts require an interpreter, the
library needs to call "path\to\cscript.exe HOOKNAME.vbs|wsf" and that
path to cscript.exe isn't the same on every system, and hook scripts
run with an empty environment so you can't rely upon the one in %PATH%
(because %PATH% is minimal or empty).

You also (to my knowledge) can't pass parameters to "bare" .VBS files,
but you can with WSF. I may be wrong though.

So...as a workaround, you can write a one-line .BAT file which calls
path\to\cscript.exe path\to\hookname.VBS %1 %2 %3 etc. - basically
passing the same parameters into that script which were passed into
the batchfile. I'm not sure how well that'll work with passing
messages back to the client, as I haven't implemented hook scripts in
WSH yet (once I get time away from my primary duties in the office, I
will hopefully be doing so).

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org