title: Delete ClearCase Views Script
body: <p>(This is a repost of a deleted question) (on request)</p>
  
  <p>What is the best ClearCase View deletion Script? I found the following on <a href="http://www.cmcrossroads.com/forums?func=view&amp;id=44045&amp;catid=31" rel="nofollow">http://www.cmcrossroads.com/forums?func=view&amp;id=44045&amp;catid=31</a> written by Yossi Sidi below</p>
  
  <p>The 2 things this script misses are the deletion of the entries in the session.dat file for CCRC views and the cleaning of server view storage and cached file directories.</p>
  
  <p>The manual steps can be found here: <a href="http://www-01.ibm.com/support/docview.wss?uid=swg21172246" rel="nofollow">http://www-01.ibm.com/support/docview.wss?uid=swg21172246</a></p>
  
  <pre><code>rmview.pl
  ==============
  #
  # rmview.pl
  #
  # This script is used to delete a view..
  # ---------------------------------------------------
  #   Fetching the UUID of the view :
  # Cleartool describe -long vob:vob_name (lists all views)
  #    -or-
  # cleartool lsview -long &lt;View_name&gt;
  # ------------------------------------------------------------------------
  # Remove sequence:-
  #   Cleartool rmview -force -uuid &lt;uuid&gt; (from a VIEW contents directory)
  #   Cleartool unreg -view -uuid &lt;uuid&gt;
  #   Cleartool rmtag -view VIEW_NAME
  #
  # Arguments:
  # view tag name :
  #
  # ASSUMED: You must be in a VOB with a view set when this tool
  # is used.
  #
  # Author: Yossi Sidi
  # email: yossis@corrigent.com
  # URL: [url=http://www.corrigent.com" target="_blank]http://www.corrigent.com[/url]
  # Date: Sep. 14, 2003
  ############################################################
  # History: 14/10/03 : Created for Corrigent
  ############################################################
  
  
  ########################
  ######## MAIN ########----------------------------------------------------------------
  ########################
  
  
  $DIV1="*************************************************************n";
  
  
  $USAGE=""USAGE ccperl.exe $0 view tag name \n EXAMPLE: ccperl.exe $0 ""My_view"" "";
  
  if ($#ARGV == 0)
  {
  $view_name = $ARGV[0];
  }
  else
  {
  `clearprompt yes_no -mask abort -default abort -pre -prompt $USAGE`;
  exit 1;
  }
  select STDOUT;
  $| = 1; # Do not buffer the STDOUT file so ccperl prog.pl &gt;out.txt
  # will have the correct sequence of report lines
  printf ($DIV1);
  printf ("View Propertiesn");
  printf (" View Tag: $view_namen");
  printf ($DIV1);
  printf ("n");
  
  $COMMAND = "cleartool lsview -l $view_name";
  @dl = `"$COMMAND"`;
  $view_uuid = "";
  foreach $dl (@dl) {
  chomp ($dl);
  printf ("$dln");
  if ( $dl =~ /^View uuid: / ) {
  $view_uuid = $'; #' reset syntax highlighter
  }
  }
  if ( $#dl &gt; 0 ) {
  #   Cleartool rmview -force -all -uuid &lt;uuid&gt; (from a VIEW contents directory)
  #   Cleartool unreg -view -uuid &lt;uuid&gt;
  #   Cleartool rmtag -view VIEW_NAME
  $rmview = "cleartool rmview -force -all -uuid $view_uuid";
  $unreg = "cleartool unreg -view -uuid $view_uuid";
  $rmtag = "cleartool rmtag -view $view_name";
  printf ($DIV1);
  printf ("Removing commandsn");
  printf ($DIV1);
  printf ("n");
  printf ("n$rmview n");
  @dl = `"$rmview"`;
  printf ("n$unreg n");
  @dl = `"$unreg"`;
  printf ("n$rmtag n");
  @dl = `"$rmtag"`;
  }
  exit 0;
  </code></pre>
  
  <p>(hmmm... interesting here is that the stackoverflow colorcoding goes wild after Perl's $' .... mini bug)</p>