Search code examples
doscleartool

How to get a ClearCase view into a command.com variable


I am writing some command.com scripts to automate some tasks involving ClearCase views. I can use cleartool lsview viewname to determine if the view exists or not. How can I get the output from the lsview subcommand into a variable such that the script does not get terminated by a cleartool error when the view does not exist?


Solution

  • If you have a recent enough ClearCase (7.1.x), you can also use:

    cleartool lsview -quick -host <registryServer>|find "viewname"
    

    (replace <registryServer> by your ClearCase registry server name)
    In a DOS script, you would redirect that to a file, and then affect the content of said file to a variable:

    set VAR=""
    cleartool lsview -quick -host <registryServer>|find "viewname" > c:\temp\aview
    IF %ERRORLEVEL% NEQ 0 goto noset
    set /p VAR=<c:\temp\aview
    :noset
    

    You can put a condition on setting that VAR with ERRORLEVEL (test done just after the cleartool command).
    The advantage is that the cleartool command doesn't generate any error message, even if the view doesn't exist.