2

I created a view using cleartool command.

cleartool mkview -tag code-count-view -nsh $ccViewspath+$ccViewName

But as it is added as part of script while executing next time , i am facing issue says that view exists already

How to verify whether view name already exists or not?

Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230

2 Answers2

2

A simple cleartool lsview yourViewTag is enough to check if a dynamic view exists.
Which is your case (your cleartool commands creates a dynamic view)

For a snapshot view, you would have the additional issue to find/check the root directory of said snapshot view, which isn't always easy.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This command works . I want to pass it to some variable and verify like below. $view= cleartool lsview $viewname if ($view -ne " " ) { create-view (viewname) } . But it doesn't work? How to convert the return value of the cleartool command as boolean? – Samselvaprabu Dec 22 '11 at 11:36
  • @Samselvaprabu: "How to convert the return value of the cleartool command as boolean?": it depends on your script language, since you need to call a system command from within your script (for instance, in bash: `$(cleartool lsview ${viewname})` – VonC Dec 22 '11 at 13:54
  • In windows batch files you can do this: IF NOT ERRORLEVEL 1 GOTO VIEW_EXISTS – Sam Mackrill Nov 05 '14 at 10:36
1

That's a problem we've already faced in ClearEnv, our ClearCase add-on tool that automatically creates working environments by predefined templates, so I can share my insights.

My advice: do the following checks:

  • Check in ClearCase registry if the view tag is already exist
  • Check if target folder is already exist

You also have to do further checks if you want to create shortcut to ClearCase explorer and could be that there are more scenarios you have to deal with

Timothy Jones
  • 21,495
  • 6
  • 60
  • 90
Tamir Gefen
  • 1,128
  • 2
  • 18
  • 35