doing SETWORKINGFOLDER and then GETVERSION in batch mode

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
jp1982
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

doing SETWORKINGFOLDER and then GETVERSION in batch mode

Post by jp1982 » Thu Oct 07, 2010 4:47 pm

Hello Vault guru's. I 've been trying to accomplish the following but cannot seem to make it work. I want, via BATCH mode for VAULT, to set the working folder and then download some files to it.

The contents of my batch file are this:
REMEMBERLOGIN

SETWORKINGFOLDER $/mainroot C:\mainroot

getversion 20 $/mainroot/sub/prog/file1.cs
getversion 1 $/mainroot/sub/prog/file2.cs
getversion 5 $/mainroot/sub/prog/file3.cs
getversion 15 $/mainroot/sub/prog/file4.cs

I then execute it via command line like this:
vault.exe BATCH -host HOST -user USER -password PASS -repository "My Repository" c:\mybatchfile.txt

The VAULT command line returns no errors, but I can't get the files I specified and the output I get looks exactly the same when I do a vault.exe LISTWORKINGFOLDERS. **I have replaced the reposfolder and localfolder

OUTPUT:
<vault>
<listworkingfolders>
<workingfolder reposfolder="folder1" localfolder="C:\some local folder />
<workingfolder reposfolder="folder2" localfolder="C:\some local folder" />
<workingfolder reposfolder="folder3" localfolder="C:\some local folder" />
</listworkingfolders>
<result success="yes" />
</vault>

What I am trying to do, is get the versions of N files specified in the BATCH file used by the vault command to my working folder keeping the folder tree structure they have in Vault. As an example lets say the file I want to download is in $/root1/sub/file1.cs, the working folder in this case $ will be c:\. Once I run the command line commands, I want to be able to find the file1.cs in the whole folder path like c:\root1\sub\file1.cs.

Is this possible to do with a batch file?

Thanks a lot for your help! :wink:

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: doing SETWORKINGFOLDER and then GETVERSION in batch mode

Post by lbauer » Fri Oct 08, 2010 12:01 pm

I got this to work when the working folder was already set. So there's something about setting the working folder in the batch file that's not working quite right. I'll do more testing.
Linda Bauer
SourceGear
Technical Support Manager

jp1982
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

Re: doing SETWORKINGFOLDER and then GETVERSION in batch mode

Post by jp1982 » Fri Oct 08, 2010 2:08 pm

lbauer wrote:I got this to work when the working folder was already set. So there's something about setting the working folder in the batch file that's not working quite right. I'll do more testing.
Awesome! If it's not too much to ask, could you send me the actual line for setting the working folder outside the batch file. I keep getting the listworkingfolders output...

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: doing SETWORKINGFOLDER and then GETVERSION in batch mode

Post by lbauer » Fri Oct 08, 2010 3:57 pm

This is the SETWORKINGFOLDER COMMAND:

Code: Select all

usage: vault.exe SETWORKINGFOLDER [options] repositoryfolder localfolder

SETWORKINGFOLDER will set the working folder for the specified repository
folder to be the local folder. All future operations on repositoryfolder
will use localfolder as a working folder by default.

Server and authentication information is specified by:
-host host

Hostname of the server to connect to. Can also use "-server".
-ssl 

Enables SSL for server connection.
-user username

Username to use when connecting to server.
-password password

Password to use when connecting to server.
-repository repositoryname

Repository to connect to.
EXAMPLE:

C:\Program Files (x86)\SourceGear\Vault Client>vault SETWORKINGFOLDER -server localhost -user USER
-password PWD -repository "My Repository" $/ C:\_Temp

I did some more testing and found that the SETWORKINGFOLDER command does set the working folder, but also lists all the other working folders every time. If you look carefully through the list of working folders, you should see the one you specified in your script.

SETWORKINGFOLDER doesn't work from a Batch file. In my tests, the folder path wasn't parsed correctly -- the "C:\ " portion of the path seems to get stripped out. This probably isn't a function intended to be used in a batch file anyway.

Also, once you run Rememberlogin, it doesn't need to be run again until you run Forgetlogin.

Here's the full Command Line Client Help. You can also get this from your own Command Line Client with the "vault helphtml" command.

http://download.sourcegear.com/misc/vau ... nt/clc.htm
Linda Bauer
SourceGear
Technical Support Manager

jp1982
Posts: 28
Joined: Fri Aug 27, 2010 3:23 pm

Re: doing SETWORKINGFOLDER and then GETVERSION in batch mode

Post by jp1982 » Tue May 03, 2011 1:08 am

Until now I started to work back on this. I've tried your solution and it works like a charm. Setting the working folder outside my batch file (bummer it does not work correctly from the file) and getting the version for each file via batch file works perfectly and it does maintain the whole file path. Thanks! :D

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: doing SETWORKINGFOLDER and then GETVERSION in batch mode

Post by lbauer » Tue May 03, 2011 10:14 am

Thanks for the update. That's good news. : )

Let me know if we can be of assistance in the future.
Linda Bauer
SourceGear
Technical Support Manager

Post Reply