Topic
  • 7 replies
  • Latest Post - ‏2012-10-30T15:32:36Z by SystemAdmin
SystemAdmin
SystemAdmin
47293 Posts

Pinned topic Command list all dynamic views separately and snapshot views separately

‏2012-10-23T07:05:36Z |
Hi,

I need a command to list all my dynamic views separately and snapshot views separately.

If any command is there, Please do let me know.

Thanks!!

Thanks,
Mohan
Updated on 2012-10-30T15:32:36Z at 2012-10-30T15:32:36Z by SystemAdmin
  • Lumart
    Lumart
    114 Posts

    Re: Command list all dynamic views separately and snapshot views separately

    ‏2012-10-23T08:08:29Z  
    Mohan,
    cleartool lsview has not options listing only dynamic view, only snapshot views, or both but separately.
    What you can do is to run cleartool lsview -l and then parse the output (look in the View attributes line).
    For example, a snaphsot view would look this way:

    Tag: Utilities
    Global path: http://...
    Server host: http://...
    Region: http://...
    Active: http://...
    View tag uuid:http://...
    View on host: http://...
    View server access path: http://...
    View uuid: http://...
    View attributes: snapshot,ucmview
    View owner: http://...
  • SystemAdmin
    SystemAdmin
    47293 Posts

    Re: Command list all dynamic views separately and snapshot views separately

    ‏2012-10-24T19:18:25Z  
    • Lumart
    • ‏2012-10-23T08:08:29Z
    Mohan,
    cleartool lsview has not options listing only dynamic view, only snapshot views, or both but separately.
    What you can do is to run cleartool lsview -l and then parse the output (look in the View attributes line).
    For example, a snaphsot view would look this way:

    Tag: Utilities
    Global path: http://...
    Server host: http://...
    Region: http://...
    Active: http://...
    View tag uuid:http://...
    View on host: http://...
    View server access path: http://...
    View uuid: http://...
    View attributes: snapshot,ucmview
    View owner: http://...
    Lumart wrote:
    > cleartool lsview has not options listing only dynamic view,
    > only snapshot views, or both but separately.
    > What you can do is to run cleartool lsview -l and then parse
    > the output (look in the View attributes line).

    That's why you should use Perl, ClearCase::Argv and its ipc mode.
    This gives something like (no access to ClearCase right now,
    UNIX command line quoting):
    perl -MClearCase::Argv -e '$ct=new ClearCase::Argv({autochomp=>1,ipc=>1});
      for ($ct->lsview([q(-s)])->qx){
        push (grep/^View attributes: snapshot/,$ct->lsview([q(-l)],$_)->qx?
          @snap : @dyn), $_;}
      END{print"snapshot views:\n",join("\n",@snap),"\n"if@snap;
          print"dynamic views:\n",join("\n",@dyn),"\n"if@dyn;}'
    

    Marc
    Updated on 2014-03-26T13:47:05Z at 2014-03-26T13:47:05Z by iron-man
  • SystemAdmin
    SystemAdmin
    47293 Posts

    Re: Command list all dynamic views separately and snapshot views separately

    ‏2012-10-25T07:59:57Z  
    Lumart wrote:
    > cleartool lsview has not options listing only dynamic view,
    > only snapshot views, or both but separately.
    > What you can do is to run cleartool lsview -l and then parse
    > the output (look in the View attributes line).

    That's why you should use Perl, ClearCase::Argv and its ipc mode.
    This gives something like (no access to ClearCase right now,
    UNIX command line quoting):
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">perl -MClearCase::Argv -e '$ct=new ClearCase::Argv({autochomp=>1,ipc=>1}); for ($ct->lsview([q(-s)])->qx){ push (grep/^View attributes: snapshot/,$ct->lsview([q(-l)],$_)->qx? @snap : @dyn), $_;} END{print"snapshot views:\n",join("\n",@snap),"\n"if@snap; print"dynamic views:\n",join("\n",@dyn),"\n"if@dyn;}' </pre>
    Marc
    Marc wrote:
    > That's why you should use Perl, ClearCase::Argv and its ipc mode.

    It strikes me that, if my suggestion may have some merits for more
    complex cases, it is overkill in the current one.
    One may even do without ClearCase::Argv...
    Something like (again: not tested!):
    
    ct lsview -l | perl -nle 
    ' 
    
    if(/^Tag: (.*)/)
    {push @unk, $tag 
    
    if $tag; $tag = $1; next
    } 
    
    if(/^View attributes: snapshot/)
    {push @snap, $tag 
    
    if $tag; undef $tag; next
    } 
    
    if(/^View attributes: dynamic/) 
    {push @dyn,  $tag 
    
    if $tag; undef $tag; next
    } END
    { print join(
    "\n", 
    "Strange views:",  @unk,  
    "") 
    
    if @unk; print join(
    "\n", 
    "Snapshot views:", @snap, 
    "") 
    
    if @snap; print join(
    "\n", 
    "Dynamic views:",  @dyn,  
    "") 
    
    if @dyn; 
    }
    '
    

    Marc
  • SystemAdmin
    SystemAdmin
    47293 Posts

    Re: Command list all dynamic views separately and snapshot views separately

    ‏2012-10-25T08:52:46Z  
    Marc wrote:
    > That's why you should use Perl, ClearCase::Argv and its ipc mode.

    It strikes me that, if my suggestion may have some merits for more
    complex cases, it is overkill in the current one.
    One may even do without ClearCase::Argv...
    Something like (again: not tested!):
    <pre class="jive-pre"> ct lsview -l | perl -nle ' if(/^Tag: (.*)/) {push @unk, $tag if $tag; $tag = $1; next } if(/^View attributes: snapshot/) {push @snap, $tag if $tag; undef $tag; next } if(/^View attributes: dynamic/) {push @dyn, $tag if $tag; undef $tag; next } END { print join( "\n", "Strange views:", @unk, "") if @unk; print join( "\n", "Snapshot views:", @snap, "") if @snap; print join( "\n", "Dynamic views:", @dyn, "") if @dyn; } ' </pre>
    Marc
    > Marc wrote:
    Now that I accessed my environment, I found that there were minor problems with both my commands.
    With the first, grouping issues in the push call...
    The result of the ternary operator was not interpreted as a list.
    Something like:
    push(@{grep(/^View attributes: snapshot/,
      $ct->lsview([q(-l)], $_)->qx)? \@snap : \@dyn}, $_);
    

    would fix this, for example.
    I.e. return a reference, and force it back to the list.
    And use parentheses to disambiguate the end of argument list.

    The other command would suffer from the fact that snapshot and dynamic views are not reported consistently by 'lsview -l' (no 'attributes' shown for dynamic views).
    One could fix this by resorting to 'ct lsview -l -prop -full' and looking at the /^Properties: / line instead of the /^View attributes: / one.

    One might also enhance the displaying by indenting the view tags in both outputs.
    Marc
    Updated on 2014-03-26T13:46:47Z at 2014-03-26T13:46:47Z by iron-man
  • SystemAdmin
    SystemAdmin
    47293 Posts

    Re:Command to list all dynamic views and snapshot views separately

    ‏2012-10-29T12:45:55Z  
    > Marc wrote:
    Now that I accessed my environment, I found that there were minor problems with both my commands.
    With the first, grouping issues in the push call...
    The result of the ternary operator was not interpreted as a list.
    Something like:
    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">push(@{grep(/^View attributes: snapshot/, $ct->lsview([q(-l)], $_)->qx)? \@snap : \@dyn}, $_); </pre>
    would fix this, for example.
    I.e. return a reference, and force it back to the list.
    And use parentheses to disambiguate the end of argument list.

    The other command would suffer from the fact that snapshot and dynamic views are not reported consistently by 'lsview -l' (no 'attributes' shown for dynamic views).
    One could fix this by resorting to 'ct lsview -l -prop -full' and looking at the /^Properties: / line instead of the /^View attributes: / one.

    One might also enhance the displaying by indenting the view tags in both outputs.
    Marc
    Dear All,

    So this means we have to use perl script to separate both Dynamic views and Snapshot views right??

    so please do share me if you have script for the same

    Thanks,
    Mohan
  • Lumart
    Lumart
    114 Posts

    Re:Command to list all dynamic views and snapshot views separately

    ‏2012-10-30T11:46:40Z  
    Dear All,

    So this means we have to use perl script to separate both Dynamic views and Snapshot views right??

    so please do share me if you have script for the same

    Thanks,
    Mohan
    Try this simple script I wrote.
    On my workstation it works fine.
  • SystemAdmin
    SystemAdmin
    47293 Posts

    Re:Command to list all dynamic views and snapshot views separately

    ‏2012-10-30T15:32:36Z  
    Dear All,

    So this means we have to use perl script to separate both Dynamic views and Snapshot views right??

    so please do share me if you have script for the same

    Thanks,
    Mohan
    Mohan wrote:
    > So this means we have to use perl script to separate both Dynamic views and Snapshot views right??

    No. Both my examples work as command lines.

    Marc