CAL mkview命令失败

时间:2012-02-16 10:00:36

标签: powershell powershell-v2.0 cleartool

我正在尝试使用Powershell中的COM对象创建一个clearcase视图。

$ccViews="\\Hostname.global.mycompany.com\cc-view\"
$ViewName="CodeCountView"
$ViewFullpath="$ccViews$ViewName"+".vws"

 $ct = new-object -com ClearCase.ClearTool

     try { 
         $ct.CmdExec('lsview $ViewName') 
     }
     catch {
         $ct.CmdExec('mkview -tag $ViewName -nsh $ViewFullpath')
      }

抛出异常。

> Exception calling "CmdExec" with "1" argument(s): "storage directory
> must be in UNC style (e.g. \\host\share\...) " At
> E:\Powershellscripts\CCountAutomation.ps1:81 char:19
> +        $ct.CmdExec <<<< ('mkview -tag $ViewName -nsh $ViewFullpath')
>     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
>     + FullyQualifiedErrorId : ComMethodTargetInvocation

有人可以帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:2)

尝试更改以下行:

$ct.CmdExec("lsview $ViewName") 

$ct.CmdExec("mkview -tag $ViewName -nsh $ViewFullpath")

使用' $variable '返回字符串$ variable 使用" $variable "将值返回给变量。

告诉你,在你的代码中,你也可以改变这个:

$ViewFullpath="$ccViews$ViewName.vws"

答案 1 :(得分:2)

为了添加(upvoted)Christian的答案,我发现的技术说明使用简单的引号:swg1PK70509

$ct.CmdExec('lsact -fmt `'%[crm_state]p`'

但是当使用变量时,需要双引号,如“how to find root [folder] for each component using cleartool?”中所示。