userreport.sh

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

SH
665
字号
#!/bin/ksh## SAMPLE NAME: userReport## FUNCTIONS:   This sample shell script generates a user's report#              based on the specified userLogin.##              The report contains the following statistics.#                o Defects owned by the user that require action now#                o Defects created by the user that require action now#                o Verify records owned by the user that are active#                o Fix records owned by the user that are active#                o Test records owned by the user that are active#                o Size records that the user must respond to#                o Approval records that the user must respond to#                o Features owned by the user that require action now#                o Features originated by the user that require action now#                o Test records owned by the user that are not ready#                o Verify records owned by the user that are not ready#                o Fix records owned by the user that are not ready#                o Files checked out by the user#                o Defects originated by the user#                o Detail Report for all defects originated by the user#                o Features originated by the user#                o Defects owned by the user#                o Features owned by the user#                o Tracks owned by the user## USAGE:       userReport userLogin## ENVIRONMENT# VARIABLE(S): CMVC_FAMILY [CMVC_BECOME]## 5765-207 (C) COPYRIGHT International Business Machines Corp. 1993,1994# 5765-202 (C) COPYRIGHT International Business Machines Corp. 1993,1994# 5622-063 (C) COPYRIGHT International Business Machines Corp. 1993,1994# 5765-397 (C) COPYRIGHT International Business Machines Corp. 1994# 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/userReport## *************************************************************************# 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 userLogin\n"  echo "This sample shell script generates a programmer's report based"  echo " on the specified userLogin.\n"  exit 1fiUSER=$1if [ -z "$CMVC_FAMILY" ]then  echo "The CMVC family must be set with the CMVC_FAMILY environment variable."  exit 1fiFAMILY=$CMVC_FAMILY# Clean up on interrupttrap 'echo "\n$0: Interrupted."; cleanup; exit 1' 2 3 15cleanup(){        rm -f /tmp/rpt$$ 2>/dev/null}found=0Report -view Users -wh "login='$USER'" -raw >/tmp/uv$$while read linedo   USERNAME=`echo $line | cut -d'|' -f1 `   found=1done </tmp/uv$$if [ $found -ne 1 ]then   echo "\nUser $USER was not found in the specified family.\n"   [ -r /tmp/uv$$ ] && rm -r /tmp/uv$$   exit 1fi[ -r /tmp/uv$$ ] && rm -r /tmp/uv$$SEPARATOR=\"===================================================================================================================================="echo "Status report for user $USER in family $FAMILY:\n"echo $SEPARATORecho "ACTION REQUIRED NOW"echo $SEPARATOR# -----------------------------------------------------------------------------# Reports in the following section:#     o Defects owned by USER that require action now#     o Defects created by USER that require action now#     o Verify records owned by USER that are active#     o Fix records owned by USER that are active#     o Test records owned by USER that are active#     o Size records that USER must respond to#     o Approval records that USER must respond to#     o Features owned by USER that require action now#     o Features originated by USER that require action now# -----------------------------------------------------------------------------### -----------------------------------------------------------------------------#   Defects owned by USER that require action now  (sorted by defect number)#   Open defects owned by USER.#   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'               # number#Report -vi DefectView -w "ownerLogin='$USER' 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="\n\nDefects I ('$USER') own that require action now:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl)-2)}{    if (NR == 1) {        printf fm, "pre", "name", "compName", "releaseName", "originLo", "addDate", "sev", "age", "abstract"        printf fm, "---", "------",  "---------------", "---------------", "--------", "--------", "---", "---", "---------------------------------------------------------------"    }    printf fm,$1,$2,$3,$4,$22,$15,$8,$10,$9}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#   Defects created by USER that require action now  (sorted by defect number)#   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'               # number#Report -view DefectView -w "originLogin='$USER' 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="\n\nDefects I ('$USER') originated that have been returned to me:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl)-2)}{    if (NR == 1) {        printf fm, "pre", "name", "compName", "releaseName", "answerDa", "ownerLog", "sev", "age", "answer", "abstract"        printf fm, "---", "------",  "---------------", "---------------", "--------", "--------", "---", "---", "---------------", "-----------------------------------------------"    }    printf fm,$1,$2,$3,$4,$17,$5,$8,$10,$7,$9}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#   Verify records owned by USER that are active  (sorted by number)# -----------------------------------------------------------------------------#SORT='sort -t"|" +0 -1 -n'#Report -view VerifyView -where "userLogin='$USER' and state='ready'" -raw |eval $SORT |awk -F"|" 'BEGIN {fm="%3.3s %6.6s %-15.15s %-15.15s %-8.8s %-8.8s %-71.71s\n"    tl="\n\nVerify records I ('$USER') own that are ready:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl)-2)}{    if (NR == 1) {        printf fm, "pre", "name  ", "type", "Reference", "addDate", "lastUpda", "Abstract"        printf fm, "---", "------",  "---------------", "---------------", "--------", "--------", "-----------------------------------------------------------------------"    }    printf fm,$10,$1,$6,$11,$3,$9,$8}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#   Fix records owned by USER that are active#   (sorted by number and release name)# -----------------------------------------------------------------------------#SORT='sort -t"|" +0 -1 -n +1 -2'#Report -view FixView -where \        "userLogin='$USER' and (state='ready' or state='active')" -raw |eval $SORT |awk -F"|" 'BEGIN {fm="%3.3s %6.6s %-15.15s %-15.15s %-8.8s %-8.8s %-15.15s %-55.55s\n"    tl="\n\nFix records I ('$USER') own that are active:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl)-2)}{    if (NR == 1) {        printf fm, "pre", "name  ", "releaseName", "compName", "state", "addDate", "Reference", "Abstract"        printf fm, "---", "------",  "---------------", "---------------", "--------", "--------", "---------------", "-------------------------------------------------------"    }    printf fm,$11,$1,$2,$3,$4,$8,$13,$7}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#   Test records owned by USER that are active (sorted by number)# -----------------------------------------------------------------------------#SORT='sort -t"|" +2 -3 -n'#Report -view TestView -where "userLogin='$USER' and state='ready'" -raw |\eval $SORT |awk -F"|" 'BEGIN {fm="%3.3s %6.6s %-15.15s %-15.15s %-15.15s %-8.8s %-64.64s\n"    tl="\n\nTest records I ('$USER') own that are ready:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl)-2)}{    if (NR == 1) {        printf fm, "pre", "name  ", "releaseName", "envName", "Reference", "addDate", "Abstract"        printf fm,"---", "------", "---------------", "---------------", "---------------", "--------", "----------------------------------------------------------------"    }    printf fm, $2,$3,$1,$4,$12,$6,$9}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#   Size records that USER must respond to#   (sorted by component, then by feature number)# -----------------------------------------------------------------------------#SORT='sort -t"|" +2 -3 +0 -1 -n'#Report -view SizeView -where "userLogin='$USER' and state='ready'" -raw |\eval $SORT |awk -F"|" 'BEGIN {fm="%3.3s %6.6s %-15.15s %-15.15s %-8.8s %-15.15s %-64.64s\n"    tl="\n\nFeatures I ('$USER') must size:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl)-2)}{    if (NR == 1) {        printf fm,"pre", "feature", "releaseName", "compName", "addDate", "Reference", "Abstract"        printf fm,"---", "-------", "---------------", "---------------", "--------", "---------------", "----------------------------------------------------------------"    }    printf fm,$12,$1,$4,$3,$6,$2,$13}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#   Approval records that USER must respond to#   (sorted by release, then by number)# -----------------------------------------------------------------------------#SORT='sort -t"|" +2 -3 +1 -2 -n'#Report -view ApprovalView -where "userLogin='$USER' and state='ready'" -raw |\eval $SORT |awk -F"|" 'BEGIN {fm="%3.3s %6.6s %-15.15s %-15.15s %-8.8s %-80.80s\n"    tl="\n\nTracks I ('$USER') must approve:"    printf "\n\n%s\n%s\n\n", tl, substr("'$SEPARATOR'", 1, length(tl)-2)}{    if (NR == 1) {        printf fm,"pre", "name  ", "Reference", "releaseName", "addDate", "Abstract"        printf fm,"---", "------", "---------------", "---------------", "-----------------", "--------------------------------------------------------------------------------"    }    printf fm,$1,$2,$10,$3,$8,$11}END {    if (NR == 0)        printf "None\n\n"    else                printf "\n" NR " record(s) selected\n\n"}'## -----------------------------------------------------------------------------#   Features owned by USER that require action now#   (sorted by feature number)# -----------------------------------------------------------------------------#SORT='sort -t"|" +1 -2 -n'#Report -view FeatureView -where "ownerLogin='$USER' and state in ('open','design')" -raw |

⌨️ 快捷键说明

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