Question

Script to run "pcli SetArchiveLocation etc" for all files in a repository

Asked by: Hecatonchires

Hi,

I need to run a command line for every file in a pvcs repository, including subdirectories.   We need to move our repository from v:\pvcs (a mapped drive) to \\server\pvcs as we need to access the repository from a windows service, and windows services can't access mapped drives   >_<

I need a dos batch/vbscript to process every file.  The help doc for the command I need to run is in the code box below

SetArchiveLocation command
Set the archive 
location for the 
specified entity
Use the SetArchiveLocation command to set the archive location 
for the specified project database, project, or versioned file. 
Typically, this location is on a networked file system, a location 
to which all authorized users have access. By default, when you 
create a project, the archive location is a directory beneath the 
project database location, but you can specify a different archive 
location using this command.
NOTE  This command is not functional for Version Manager 
5.3/6.0 project roots.
Privileges required Modify Project. For more information on privileges, see the PVCS 
Version Manager Administrators Guide.
Alias SAL
Exit codes 0 Successful command completion
-2 PCLI command not found
-3 A non-PCLI related error or a command-specific error
-6 An invalid argument was specified
-7 An argument for a flag that is not needed
-8 A missing argument for a flag
-9 Wrong type was specified for an options argument
For information about... See...
Listing versioned files ListVersionedFiles command on 
page 168
Reporting archive and 
revision information for 
versioned files
Vlog command on page 227PVCS Version Manager PCLI Users Guide and Reference
206 Chapter 3  PCLI Command Reference  
-10 The specified file name cannot be read
-11 A required argument is missing
-12 A security exception occurred
-13 An unknown problem
See the appendix, Exit Codes, on page 241 for more detailed 
definitions of the exit codes.
Syntax SetArchiveLocation [options] -aarchive_location [entity]
Where:
archive_location specifies the path to the archive directory. You 
can set the archive location of a project to either a relative path, 
for example, /prj1, or a full absolute path, for example, 
H:\Samples\archives\prj1. If you set the path to a relative path, 
the location will be appended to the parents computed archive 
location. The -a option is required.
entity specifies a project or versioned file for which you are 
setting the archive location. You need not specify an entity if you 
want to set the archive location for the current project or project 
database.
NOTE  The current project is set using either the -pp option (as 
described below) or the PCLI_PP variable. A project database is 
set by using either the -pr option (as described below) or the 
PCLI_PR variable.
Options
To substitute variables and use list files for additional options, see 
Command Options on page 26 for more information.
-a -aarchive_location
Specifies the path to the archive directory. You can set the 
archive location of a project to either a relative path, for SetArchiveLocation command 207
PVCS Version Manager PCLI Users Guide and Reference
example, /prj1, or a full absolute path, for example, 
H:\Samples\archives\prj1. If you set the path to a relative path, 
the location will be appended to the parents computed archive 
location. This is required.
-h Display help for the command. The action terminates after it 
processes the -h option even if you specify other options.
-id -iduser id[:user_password]
Specifies a user ID and/or password for project databases and 
projects that have an access control database enabled. It 
overrides the value of the PCLI_ID variable for a single command. 
If VLOGIN or LDAP is the login source, use -id to specify your 
user IDand password too, if a password is assigned to your user 
ID. If VLOGIN or LDAP is not the login source, your user ID is 
predetermined by your login source, but you must still use -id to 
enter your password, if you have one. For example, 
-id:PassWord.
-pp -ppproject_path
Specifies the current project or folder for which to set the 
archive location. This option overrides the value of the PCLI_PP 
variable for a single command execution. If no project is 
specified, the PCLI_PP variable is used. 
-pr -prproject_database
Specifies the project database for which to set an archive 
location. This option overrides the value of the PCLI_PR variable 
for a single command execution. A project database is required 
for this command. If no project database is specified, the PLCI_PR 
variable is used. If it is not defined, then an error message is 
displayed and the command is aborted.
Examples Example 1: The following example changes the archive location 
for the Checkers project to the specified directory. 
pcli setarchivelocation -prd:\producta -pp/checkers
-aH:\archives\producta\checkersPVCS Version Manager PCLI Users Guide and Reference
208 Chapter 3  PCLI Command Reference  
Example 2: The following example sets the archive location for a 
project database to a value specified in a variable named 
archivelocation:
pcli setarchivelocation -prd:\productb -a$archivelocation

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-02-24 at 22:19:06ID24175001
Tags

pvcs

,

pcli

,

vbscript

,

dos batch

Topics

PVCS

,

Windows Batch Scripting

,

VB Script

Participating Experts
1
Points
500
Comments
8

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Linux Version Control Repository
    I want to find out whether a linux box could provide a version control system for a forms program like mandoforms (mandoforms.com) that is to be developed using a server as a repository. This would mean request for files from a 2000 client machine would pull files and upload...
  2. Repository
    Hi, How to add formulas / templates to repository (Crystal / Database), so that we can reuse them thank you
  3. repository
    What is meant by oracle repository?
  4. repository for actions?
    Hi there, been away from photoshop for a while... and recently came back and i remember they used to be some great repositories for download free actions, you could search for text effects, image effects, processing effects etc.. But i just can't seem to find them, the ones ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: AmazingTechPosted on 2009-02-25 at 05:58:11ID: 23733571

Hmmm... Not too sure what the exact pcli command is. Here you can process every file.

for /r "v:\pvcs" %%a in (*.*) do (
    pcli setarchivelocation "%%a" "\\server\pvcs"
)
                                              
1:
2:
3:

Select allOpen in new window

 

by: AmazingTechPosted on 2009-02-25 at 06:04:11ID: 23733611

 

by: HecatonchiresPosted on 2009-02-25 at 14:35:09ID: 23739393

Sorry I've taken so long to respond AT, posted this just as I was leaving to go home.  Is your first post batch or vbscript?

No, I've already read that link.  Not quite what I need, and as no-one appears to know our Licence details, I can't get onto the Serena site to ask myself.

 

by: AmazingTechPosted on 2009-02-25 at 15:25:35ID: 23739825

My script is a batch script.

%%a is the variable for each file using full path.

 

by: HecatonchiresPosted on 2009-02-25 at 16:12:57ID: 23740163

ok.  how do I take that %%a, remove '-arc' from the end of it, and change v:\ at the front to \\server\pvcs

eg:  v:\pvcs\java\source\bob.java-arc         (the -arc is the pvcs specific extension on the archive)
to
v:\pvcs\java\source\bob.java                    (how I have to actually refer to the file)
to
\\server\pvcs\pvcs\java\source\bob.java       (yes, two pvcs folders)

 

by: AmazingTechPosted on 2009-02-25 at 21:00:33ID: 23741696

I am just stepping out so I haven't tested this.

SETLOCAL ENABLEDELAYEDEXPANSION
for /r "v:\pvcs" %%a in (*.*) do (
    Set VFile=%%a
    Set ServerFile=\\server\pvcs%%~pnxa
    Set File=!File:-arc=!
    Set ServerFile=!ServerFile:-arc=!
    Echo !File!
    Echo !ServerFile!
)

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:

Select allOpen in new window

 

by: HecatonchiresPosted on 2009-02-25 at 22:19:38ID: 31550936

Thankyou for this AT.  I ended up developing something in vbscript, but you sent me in the right direction

 

by: HecatonchiresPosted on 2009-02-25 at 22:25:25ID: 23742040

In the code box below is the vbscript I used for this solution.  It's a massive pain, and I hate PVCS.  For anyone looking, the correct syntax for  SetArchiveLocation is:

pcli SetArchiveLocation -pr\\server\share\pvcs -a\\server\share\PVCS\archives\path\to\file.txt-arc V:/PVCS/archives/path/to/file.txt

Note that the -arc is left on for -a, and that its removed for the entity, and the slashes are reversed.

Option Explicit
 
'on error resume next
 
const FOR_READING = 1
const FOR_WRITING = 2
const FOR_APPENDING = 8
const NEW_PATH = "\\it100\pvcs"
const cmd_template = "pcli SetArchiveLocation -pr[project_database] -a[new_path] [file]"
 
 
Dim fso
Dim objShell
Dim log_file
Dim cmd
Dim return_code
 
Set fso = WScript.CreateObject ("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
Set log_file = fso.OpenTextFile("d:\pvcs_migrate.log", FOR_WRITING, true)
 
ShowSubFolders fso.GetFolder("v:\pvcs\archives")
 
log_file.close
Set log_file = nothing
Set objShell = nothing
Set fso = nothing
 
Sub ShowSubFolders(Folder)
	Dim SubFolder
	Dim Files
	Dim File
	Dim path
    For Each Subfolder In Folder.SubFolders
        Set files = SubFolder.Files
        For Each file In files
            Log File.name
			cmd = cmd_template
			path = StripArc(file.path)  'remove trailing -arc
			path = replace(path, "v:\pvcs\archives", "")'remove leading v:\pvcs\archives
			path = replace(path, "\", "/") 'swap slashes
			cmd = replace(cmd, "[project_database]", NEW_PATH & "\pvcs")
			cmd = replace(cmd, "[new_path]", NEW_PATH & right(file.path, len(file.path)-2))
			cmd = replace(cmd, "[file]", path)
			Log cmd
			on error resume next
			return_code = runCmd(cmd)
			if return_code <> 0 then
				Log "ERROR WITH ABOVE STATEMENT"
				err.clear
			else
				Log "SUCCESS"
			end if
			on error goto 0
        Next
        ShowSubFolders Subfolder
    Next
End Sub
 
Function runCmd(cmd)
	Dim objExecObject
	Dim strText
	Set objExecObject = objShell.Exec(cmd)
 
	' wait for it to finish
	do while objExecObject.Status = 0
		WScript.Sleep 100
	loop
 
	do while not objExecObject.StdOut.AtEndOfStream
		strText = objExecObject.StdOut.ReadLine()
		Log strText
	loop
	runCmd = objExecObject.ExitCode
End Function
 
function Log(msg)
	msg = fmtDateYYYYMMDD(Now) & " " & fmtTimeHHMMSS(Now) & " " & msg
	Wscript.stdout.writeline(msg)
	log_file.WriteLine(msg)
 
	Log = true
End Function
 
function fmtDateYYYYMMDD(thisDate)
	'debug("Function: fmtDateYYYYMMDD")
	fmtDateYYYYMMDD = PadZero(year(thisDate), 4) & PadZero(month(thisDate), 2) & PadZero(day(thisDate), 2)
end function
 
 
function fmtTimeHHMMSS(thisTime)
	'debug("Function: fmtTimeHHMMSS")
	fmtTimeHHMMSS = PadZero(Hour(thisTime), 2) & PadZero(Minute(thisTime), 2) & PadZero(Second(thisTime), 2)
end function
 
 
function PadZero( thisInt, length )
	Dim sTemp
	sTemp = String(length, "0")
	sTemp = sTemp & thisInt
	sTemp = Right(sTemp, length)
	PadZero = sTemp
end Function
 
Public Function Reverse(sIn)
    Dim nC
    Dim sOut
 
    For nC = Len(sIn) To 1 Step -1
        sOut = sOut & Mid(sIn, nC, 1)
    Next
    
    Reverse = sOut
End Function
 
Function StripArc(str)
	if len(str) >=4 then
		if right(str, 4) = "-arc" then
			StripArc = left(str, len(str) - 4)
		end if
	else
		StripArc = str
	end if
End Function
 
Function StripFile(str)
	Dim rev_str : rev_str = reverse(str)
	StripFile = reverse(mid(rev_str, instr(rev_str, "\"), len(str)))
End Function
 
Function StripPath(str)
	Dim rev_str : rev_str = reverse(str)
	StripPath = reverse(left(rev_str, instr(rev_str, "\")))
End Function
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:

Select allOpen in new window

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...