reassignwork.sh

来自「CMVC是IBM和许多跨国公司的缺陷管理工具。这里给出了很多在Linux下用KS」· Shell 代码 · 共 405 行

SH
405
字号
#!/bin/ksh# @(#)06        1.3  samples/reassignWork.sh, samples, samples-client 1/3/03 17:16:06## VC FILE_NAME: /family/ausbo/vc/0/0/3/3/s.06## SAMPLE NAME: reassignWork## FUNCTIONS:   This sample shell script will re-assign all current work#              and objects owned by userLogin1 to userLogin2.   The user#              running this script must have the appropriate authority to#              modify and reassign objects.## USAGE:       reassignWork userLogin1 userLogin2## ENVIRONMENT# VARIABLE(S): CMVC_FAMILY [CMVC_BECOME]## ORIGINS:     27## 5765-039 (C) COPYRIGHT International Business Machines Corp. 1991,1993# 5765-207 (C) COPYRIGHT International Business Machines Corp. 1993# 5765-202 (C) COPYRIGHT International Business Machines Corp. 1993# 5622-063 (C) COPYRIGHT International Business Machines Corp. 1993# 5765-069 (C) COPYRIGHT International Business Machines Corp. 1991,1993# All Rights Reserved# Licensed Materials - Property of IBM## US Government Users Restricted Rights - Use, duplication or# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.###           NOTICE TO USERS OF THE SOURCE CODE EXAMPLES## INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOURCE CODE# EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT# WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A# PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE# OF THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS,# IS WITH YOU.  SHOULD ANY PART OF THE SOURCE CODE EXAMPLES PROVE# DEFECTIVE, YOU (AND NOT IBM OR AN AUTHORIZED RISC System/6000* WORKSTATION# DEALER) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR# CORRECTION.## * RISC System/6000 is a trademark of International Business Machines#   Corporation.## /usr/lpp/cmvc/samples/reassignWork################################################output(){ echo "$outMsg" | tee -a $LOG}################################################source=$1target=$2OWNER=`whoami`IFSsave=$IFSif [[ $# -lt 2 ]] then  echo "\aUSAGE: reassignWork source target"  exit 1fiLOGDIR="/tmp/reassign"if [[ ! -d $LOGDIR ]] then   mkdir $LOGDIR   chown $OWNER.staff $LOGDIR   chmod 777 $LOGDIRfiLOG="/tmp/reassign.$source.$target.log">$LOGprint "reassignWork $source $target" >>$LOGERROR="N"IFS=$IFSsaveprint "Validating Target Id (userLogin2)" >>$LOGReport -vi users -wh "login='$target'" -raw  | read recordLOGIN=`(echo $record|cut -d'|' -f1)`NAME=`(echo $record|cut -d'|' -f2)`AREA=`(echo $record|cut -d'|' -f3)`ADDRESS=`(echo $record|cut -d'|' -f4)`ADDDATE=`(echo $record|cut -d'|' -f5)`DROPDATE=`(echo $record|cut -d'|' -f6)`LASTUPDATE=`(echo $record|cut -d'|' -f7)`SUPERUSER=`(echo $record|cut -d'|' -f8)`if [[ -z $LOGIN ]] then   outMsg="userLogin2 NOT found"   output   exit 1 elif [[ -n $DROPDATE ]] then    outMsg="userLogin2 NOT Active"   output   exit 1fioutMsg="Reassigning work from $source to $target"outputprint "Checking Defects..." >>$LOGReport -view defectv -wh "ownerlogin='$source' and state not in ('canceled','closed')" -ra |while read recorddo   DEFECTNAME=`(echo $record|cut -d'|' -f2)`   outMsg="FOUND|Reassigning Defect $DEFECTNAME to $target..."   output   Defect -assign $DEFECTNAME -owner $target    rcode=$?   if [[ $rcode != 0 ]]    then     outMsg="ERROR|Reassigning Defect ownership $DEFECTNAME to $target... ERROR!!"     output     ERROR="Y"   fidoneReport -view defectv -wh "originlogin='$source' and state not in ('canceled','closed')" -ra |while read recorddo  DEFECTNAME=`(echo $record|cut -d'|' -f2)`  outMsg="FOUND|Reassigning Defect $DEFECTNAME to $target..."  output  Defect -modify $DEFECTNAME -originator $target   rcode=$?  if [[ $rcode != 0 ]]    then     outMsg="ERROR|Reassigning Defect originator $DEFECTNAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Features..." >>$LOGReport -view featureview -wh "ownerlogin='$source' and state not in ('canceled','closed')" -ra |while read recorddo  FEATURENAME=`(echo $record|cut -d'|' -f2)`  outMsg="FOUND|Reassigning Feature $FEATURENAME to $target..."  output  Feature -assign $FEATURENAME -owner $target  >>$LOG 2>>$LOG  rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Feature $FEATURENAME to $target... ERROR!!"     output     ERROR="Y"  fidoneReport -view featureview -wh "originlogin='$source' and state not in ('canceled','closed')" -ra  |while read recorddo  FEATURENAME=`(echo $record|cut -d'|' -f2)`  outMsg="FOUND|Reassigning Feature $FEATURENAME to $target..."  output  Feature -modify $FEATURENAME -originator $target   rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Feature $FEATURENAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Tracks..." >>$LOGReport -view trackview -wh "userlogin='$source' and state not in ('complete')" -ra  |while read recorddo  RELEASENAME=`(echo $record|cut -d'|' -f1)`  DEFECTNAME=`(echo $record|cut -d'|' -f2)`  outMsg="FOUND|Reassigning Track $DEFECTNAME to $target..."  output  Track -assign -to $target -defect $DEFECTNAME -release $RELEASENAME  2>>$LOG  rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Track $DEFECTNAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Size Records" >>$LOGReport -vi sizeview -where "userlogin='$source' and state not in ('accept','reject')" -ra  |while read recorddo  FEATURENAME=`(echo $record|cut -d'|' -f1)`  COMPNAME=`(echo $record|cut -d'|' -f3)`  RELEASENAME=`(echo $record|cut -d'|' -f4)`  outMsg="FOUND|Reassigning Size record $FEATURENAME to $target..."  output  Size -assign -to $target -component $COMPNAME -release $RELEASENAME -feature $FEATURENAME    rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Size record $FEATURENAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Fix Records" >>$LOGReport -view fixv -where "userlogin='$source' and state='active'" -ra |while read recorddo  DEFECTNAME=`(echo $record|cut -d'|' -f1)`  RELEASENAME=`(echo $record|cut -d'|' -f2)`  COMPNAME=`(echo $record|cut -d'|' -f3)`  outMsg="FOUND|Reassigning Fix record $DEFECTNAME to $target..."  output  "Fix" -assign -to $target -component $COMPNAME -release $RELEASENAME -defect $DEFECTNAME  2>>$LOG  rcode=$?  if [[ $rcode != 0 ]]    then     outMsg="ERROR|Reassigning Fix record $DEFECTNAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Test Records" >>$LOGReport -vi testview -where "userlogin='$source' and state in ('ready','notReady')" -ra |while read recorddo  RELEASENAME=`(echo $record|cut -d'|' -f1)`  DEFECTNAME=`(echo $record|cut -d'|' -f3)`  ENVNAME=`(echo $record|cut -d'|' -f4)`  outMsg="FOUND|Reassigning Test record $DEFECTNAME to $target..."  output  echo "\"Test\" -assign -to $target -environment $ENVNAME -release $RELEASENAME -defect $DEFECTNAME -tester $source " >>$LOG  Test -assign -to $target -environment $ENVNAME -release $RELEASENAME -defect $DEFECTNAME -tester $source   rcode=$?  if [[ $rcode != 0 ]]    then     outMsg="ERROR|Reassigning Test record $DEFECTNAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Verification Records" >>$LOGReport -view verifyv -wh "userlogin='$source' and state in ('notReady','ready')" -ra |while read recorddo  DEFECTNAME=`(echo $record|cut -d'|' -f1)`  DUPDEFECTNAME=`(echo $record|cut -d'|' -f13)`  if [[ $TYPE = "original" ]]   then     outMsg="FOUND|Reassigning Verification record $DEFECTNAME to $target..."     output     Verify -assign -to $target -defect $DEFECTNAME -tester $target  2>>$LOG     rcode=$?   else     outMsg="FOUND|Reassigning Verification record $DUPDEFECTNAME to $target..."     output     Verify -assign -to $target -defect $DUPDEFECTNAME -tester $source  2>>$LOG     rcode=$?  fi  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Verification record $DEFECTNAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Approval Records" >>$LOGReport -vi approvalview -where "userlogin='$source' and state='ready'" -ra |while read record do  DEFECTNAME=`(echo $record|cut -d'|' -f2)`  RELEASENAME=`(echo $record|cut -d'|' -f3)`  outMsg="FOUND|Reassigning Approval record $DEFECTNAME to $target..."  output  Approval -assign -to $target -release $RELEASENAME -defect $DEFECTNAME    rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Approval record $DEFECTNAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Environment Records" >>$LOGReport -view envview -where "userlogin='$source'" -ra |while read recorddo  NAME=`(echo $record|cut -d'|' -f1)`  RELEASENAME=`(echo $record|cut -d'|' -f2)`  outMsg="FOUND|Reassigning Environment record $NAME to $target..."  output  Environment -modify $NAME -tester $target -release $RELEASENAME   rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Environment record $NAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Components..." >>$LOGReport -view compv -wh "userlogin='$source'" -raw |while read recorddo  NAME=`(echo $record|cut -d'|' -f1)`  outMsg="FOUND|Reassigning Component $NAME to $target..."  output  Component -modify $NAME -owner $target   rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Component $NAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Levels..." >>$LOGReport -view levelview -wh "userlogin='$source' and state not in ('complete')" -ra |while read recorddo  NAME=`(echo $record|cut -d'|' -f1)`  RELEASENAME=`(echo $record|cut -d'|' -f2)`  outMsg="FOUND|Reassigning Level $NAME to $target..."  output  Level -assign $NAME -to $target -release $RELEASENAME  2>>$LOG  rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Level $NAME to $target... ERROR!!"     output     ERROR="Y"  fidoneprint "Checking Approver Records" >>$LOGReport -vi approverview -where "userlogin='$source'" -ra |while read recorddo  RELEASENAME=`(echo $record|cut -d'|' -f1)`  outMsg="FOUND|Reassigning Approver $RELEASENAME to $target..."  output  Approver -delete -login $source -release $RELEASENAME   rcode=$?  if [[ $rcode = 0 ]]   then     Approver -create -login $target -release $RELEASENAME      rcode=$?   if [[ $rcode != 0 ]]     then       outMsg="ERROR|Reassigning Approver $RELEASENAME to $target... ERROR!!"       output       ERROR="Y"   fi   else     outMsg="ERROR|Error during Approver delete"     output     ERROR="Y"  fidoneprint "Checking Releases..." >>$LOGReport -view releaseview -wh "userlogin='$source'" -ra |while read recorddo  NAME=`(echo $record|cut -d'|' -f1)`  outMsg="FOUND|Reassigning Release $NAME to $target..."  output  Release -modify $NAME -owner $target   rcode=$?  if [[ $rcode != 0 ]]   then     outMsg="ERROR|Reassigning Release $NAME to $target... ERROR!!"     output     ERROR="Y"  fidoneif [[ $ERROR = "N" ]] then   outMsg="COMPLETE|$source|$family" else   outMsg="ERRORS"fioutputexit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?