Today I needed to add Subversion as a Windows service. The docs pointed me to the "sc" tool. This seemed like a simple tool but for the life of me I couldn't get it to work. Every time I ran the tool I would get a help message back. Here is an example of what I was trying to run:
sc create svnserve binpath="c:\svnserve\svnserve.exe --service
--root c:\repos" displayname="Subversion" depend=tcpip start=auto
I noticed something odd in the help message though:
The option name includes the equal sign.
I looked again at the web site instructions and noticed that after every option there was a space. I was convinced that was just a typo, or formatting used to wrap nicely in a browser. However, on a whim I tried it:
sc create svnserve binpath= "c:\svnserve\svnserve.exe --service
--root c:\repos" displayname= "Subversion" depend= tcpip start= auto
Guess what? It worked. For some reason the person who created sc.exe decided to make the syntax: opt1= val1. I was just crazy thinking that this syntax would be fine: opt1=val1.
Seriously - can someone tell me why this syntax would be used? Would it have been so hard to support a simple opt1=val1 type syntax like, oh, most other command line tools?
Archived Comments
Perhaps you should have a look at the new PowerShell. I love it since it has a far better structure.
If sc isn't available to other users, there is a program created specifically to run Subversion as a Windows service: SVNService.exe. Take a look at the Mere Moments Guide to installing a Subversion server on Windows for more information:
http://www.excastle.com/blo...
Just to clarify - since SVN 1.4 - Subversion has had the ability to run as a service built in...
http://www.thecrumb.com/200...
The 'sc' command is a Windows shell command - and in regards to Ray's frustration - it's a feature, not a bug :)
I never noticed this as I cut-n-pasted the command string - but I'm going to add a note to my blog post and mention it!
Perhaps the weird command line syntax is the result of a library he is using inside the sc command to parse the command line args for him. That is my guess.
Hello Ray,
Which docs did you use? The ones at
http://svn.collab.net/repos...
warn you about this..
"Note that the command-line syntax for SC is rather
odd. Key/value pairs are specified as "key= value"
(without the double-quotes). The "key=" part must
not have any spaces, and the "value" part MUST be
separated from the "key=" by a space."
tang, I don't remember the URL.
The weird syntax is because they tokenized the command line on the space character instead of tokenizing once for the spaces and once for the equals. Laaaaaaazy programmers. If SVNService doesn't work for you (which it should), you can also do it using FireDaemon, which is super easy to set up.
I spent with sc.exe two nights and then I finally found this help. Could you please make it more SEO friendly, because it's unfortunatelly hard to find.
Greate find. I have also spend the whole day trying to figure what was going on. It wasn't a really pleasant experience.
I used these docs as a reference: http://support.microsoft.co...
I have also noticed the strange syntacsis they used in the examples, but I didn't think it was important.