使用korn shell脚本锁定clearcase标签类型

问题描述 投票:0回答:1

我试图使用korn shell脚本锁定标签类型,但我无法锁定。 因为我是Korn脚本的新手,所以有人可以帮助我。

这是我目前的代码:

cmUsers="user1,user2";
myuserName=$ENV{LOGNAME};

#checking whether current user is part of cmUsers list or not.

if [[ "$cmUsers" =~ m/$myUserName/i ]]

# if user belongs to cmUsers list, then trying to lock the lable type,
# if it fails exiting the process, else printing the success message

  "ct lock -nuser \"$cmUsers\" lbtype:${label}@/vobs/admin_rec" ;then
    die"Unable to lock label type: \"${label}\"\n";
  else
    print "Label ${label} has been successfully locked by $cmUsers"
  fi
sh ksh clearcase clearcase-ucm
1个回答
0
投票

除了shebang之外,一个简单的提示是避免在脚本中使用别名(ct):使用完整命令cleartool。 另见“Ksh Scripting”和“ksh class

#!/bin/ksh
cmUsers="user1,user2";
myuserName=$ENV{LOGNAME};

#checking whether current user is part of cmUsers list or not.
if [[ "$cmUsers" =~ m/$myUserName/i ]]; then
    # if user belongs to cmUsers list, then trying to lock the lable type, 
    # if it fails exiting the process, else printing the success message
    cleartool lock -nuser \"$cmUsers\" lbtype:${label}@/vobs/admin_rec"
    if [ $? -ne 0 ]; then
        echo "CRITICAL: Unable to lock label type: \"${label}\""
        exit 1
    fi
    echo "Label ${label} has been successfully locked by $cmUsers"
fi

然而,像$ENV{LOGNAME}这样的表达式指出它可能不是ksh或任何其他shell,而是ratperl(如果你使用的是ClearCase 7.x或更多):请参阅“About ratlperl and its impact on cqperl and ccperl

在这种情况下,删除shebang,并尝试执行您的脚本:

ccperl yourScript.pl 
© www.soinside.com 2019 - 2024. All rights reserved.