managerreport.sh

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

SH
425
字号
#!/bin/ksh## SAMPLE NAME: managerReport## FUNCTIONS:   This sample shell script generates a manager's report#              based on the specified areas or departments of interest.##              The report contains the following statistics:#                 o Open defects owned by the specified ownerarea (DEPTS)#                 o Returned defects originated by originarea (DEPTS)#                 o Ready test records owned by userarea (DEPTS)#                 o Active size records owned by userarea (DEPTS)#                 o Active features owned by ownerarea (DEPTS)#                 o Returned features originated by originarea (DEPTS)#                 o Blocked or NotReady test records owned by ownerarea (DEPTS)#                 o Active defects owned by ownerarea (DEPTS)## USAGE:       managerReport areaName [ areaName .... ]## 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/managerReport## *************************************************************************# Note: This file produces 132 column output and is easier to view and#       edit if displayed in 132 columns.# *************************************************************************#if [ $# -eq 0 ]then  echo "\nusage: $0 areaName [ areaName ... ]\n"  echo "This sample shell script generates a manager's report based on"  echo "the specified areas or departments of interest.\n"  exit 1fiif [ -z "$CMVC_FAMILY" ]then  echo "The CMVC family must be set with the CMVC_FAMILY environment variable."  exit 1fi# get the list of departments or areas from the command linelist=""userDepts=$*for dept in $userDeptsdo  list="$list,'$dept'"doneDEPTS="$list"# remove the leading comma from the listDEPTS=$(print ${DEPTS#,})echo $DEPTSFAMILY=$CMVC_FAMILY# Define a SEPARATOR line of 132 "=" symbols.#SEPARATOR=\"===================================================================================================================================="echo "Status report for area(s) $DEPTS in family $FAMILY:\n"echo $SEPARATORecho "ACTION REQUIRED NOW"echo $SEPARATOR## -----------------------------------------------------------------------------#       Open defects by Dept or area.#       Un-comment one desired "sort" option.# -----------------------------------------------------------------------------#SORT='sort -t"|" +7 -8 +1 -2 -n +3 -4'    # severity, number, release#SORT='sort -t"|" +1 -2 -n'               # numberReport -vi DefectView -w "ownerArea in ($DEPTS) and state='open'" -raw |eval $SORT |awk -F"|" 'BEGIN {fm="%3.3s %6.6s %-15.15s %-15.15s %-8.8s %-8.8s %-3.3s %-3.3s %-63.63s\n"    tl="Open defects owned by personnel in area(s) '$DEPTS':"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl))}{    if (NR == 1) {        printf fm, "pre", "name", "compName", "releaseName", "originLo", "ownerLog", "sev", "age", "abstract"        printf fm, "---", "------",  "---------------", "---------------", "--------", "--------", "---", "---", "---------------------------------------------------------------"    }    printf fm,$1,$2,$3,$4,$22,$5,$8,$10,$9}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#       Returned defects originated by Area#       Un-comment one desired "sort" option.# -----------------------------------------------------------------------------#SORT='sort -t"|" +7 -8 +1 -2 -n +3 -4'    # severity, number, release#SORT='sort -t"|" +1 -2 -n'               # numberReport -vi DefectView -w "originArea in ($DEPTS) and state='returned'" -raw |eval $SORT |awk -F"|" 'BEGIN {fm="%3.3s %6.6s %-15.15s %-15.15s %-8.8s %-8.8s %-3.3s %-3.3s %-15.15s %-47.47s\n"    tl="Returned defects originated by personnel in area(s) '$DEPTS':"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl))}{    if (NR == 1) {        printf fm, "pre", "name", "compName", "releaseName", "originLo", "ownerLog", "sev", "age", "answer", "abstract"        printf fm, "---", "------",  "---------------", "---------------", "--------", "--------", "---", "---", "---------------", "-----------------------------------------------"    }    printf fm,$1,$2,$3,$4,$22,$5,$8,$10,$7,$9}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#       Test records owned by dept that are ready# -----------------------------------------------------------------------------#SORT='sort -t"|" +2 -3 -n'Report -vi TestView -w "userArea in ($DEPTS) and state='ready'" -ra |\eval $SORT |awk -F"|" 'BEGIN {    fm="%3.3s %6.6s %-15.15s %-15.15s %-15.15s %-8.8s %-64.64s\n"    tl="Test records owned by personnel in area(s) '$DEPTS' that are ready:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl))}{    if (NR == 1) {        printf fm,"pre", "name  ", "releaseName", "reference", "envName", "lastUpda", "Abstract"        printf fm, "---", "------", "---------------", "---------------", "---------------", "--------", "----------------------------------------------------------------"    }    printf fm,$2,$3,$1,$12,$4,$7,$9}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#       Active Size records#       (sorted by component, then by feature number)# -----------------------------------------------------------------------------#SORT='sort -t"|" +2 -3 +0 -1 -n'Report -vi SizeView -w "userArea in ($DEPTS) and state='ready'" -ra |\eval $SORT |awk -F"|" 'BEGIN {    fm="%3.3s %6.6s %-15.15s %-8.8s %-8.8s %-87.87s\n"    tl="Size records owned by personnel in area(s) '$DEPTS' that are ready:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl))}{    if (NR == 1) {        printf fm,"pre", "feature", "compName", "addDate", "lastUpdate", "Abstract"        printf fm, "---", "-------", "---------------", "--------", "--------", "---------------------------------------------------------------------------------------"    }    printf fm,$12,$1,$3,$6,$11,$13}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'

⌨️ 快捷键说明

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