showcommonfiles.sh

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

SH
163
字号
#!/bin/ksh## SAMPLE NAME: showCommonFiles## FUNCTIONS:   This sample shell script shows common files and releases.#              The CMVC_RELEASE environment variable must be set #              if the release name is not specified on the command line.## USAGE:       showCommonFiles filePathName [releaseName]## ENVIRONMENT# VARIABLE(S): CMVC_FAMILY [CMVC_RELEASE] [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/showCommonFiles##-----------------------------------------------+# Cleanup on exit or interrupt.                 |#-----------------------------------------------+terminate(){        cleanup        exit 1}cleanup(){        rm -f $COMMON 2>/dev/null}yesno(){        read REPLY        case "$REPLY" in                n|no|N|NO) YESNO=no ;;                *) YESNO=yes ;;        esac}#-----------------------------------------------+# Begin program.                                |# Check for proper args or give usage.          |#-----------------------------------------------+if [ $# -eq 0 ]then        echo "\nusage: $0 filePathName [releaseName]\n"        echo "This sample shell shows common files and releases. \n"        echo "The CMVC_RELEASE environment variable must be set\n"        echo "if the release name is not specified on the command line.\n"        exit 1fiif [ -z "$CMVC_FAMILY" ]then  echo "The CMVC family must be set with the CMVC_FAMILY environment variable."  exit 1fi#-----------------------------------------------+# Setup the environment.                        |#-----------------------------------------------+trap 'echo "\n$0: Interrupted."; cleanup; exit 1' 2 3 15COMMON=/tmp/fpc$$#-----------------------------------------------+# Check for the release off the cmd line or     |# in the environment. Exit if neither.          |#-----------------------------------------------+if [ -z "$2" ]then        if [ -z "$CMVC_RELEASE" ]        then                echo "The Release must be set in environment or given on the command line."                exit 1        else                release=$CMVC_RELEASE        fielse        release=$2fi#-----------------------------------------------+# Resolve the path name of the file.  What was  |# given on the COMMAND line may be short.       |#-----------------------------------------------+echo "Resolving the path name of the file. Please wait..."path=`File -resolve $1 -release $release -quiet` || terminate[ "$path" != "$1" ] && echo "\nResolving '$1' to '$path'."echo "Issuing the query. This step will take a while. Please wait..."#-----------------------------------------------+# Obtaining the Common files and releases.      |#-----------------------------------------------+# The following query is a larger version of the query belowReport -view FileView -raw -where "nuDropDate is null and releaseName<>'$release' and nuVersionId in (select nuVersionId from Files where pathId in (select id from Path where name='$path') and releaseId in (select id from Releases where name='$release'))" > $COMMON# The following query is shorter than the one above but involves a number of # tables (including the tables used by the views) that is greater than 15 # and this causes the error SQL0129 in DB2/6000.# Thus, if you are not using DB2, you could use the following query by uncommenting the# line.##Report -view FileView -raw -where "nuDropDate is null and releaseName<>'$release' and nuVersionId=(select nuVersionId from FileView where nuPathName='$path' and releaseName='$release')" > $COMMONif [ -s $COMMON ]then        awk -F"|" 'BEGIN {           printf "\n%s\n", "There are common files associated with\n'$path'"           printf "\n%-16.16s %-9.9s %-45.45s\n","Release","Version","Path"           printf "%-16.16s %-9.9s %-45.45s\n\n","----------------",\                "---------",\                "---------------------------------------------"        }        {        if (length($1) > 45) start = (length($1)-44)                else start = 0;        printf "%-16.16s %-9.9s %45.45s\n",$2,$4,substr($1,start)        }' $COMMONelse        echo "\nNo common files and releases."ficleanupexit 0# end of file

⌨️ 快捷键说明

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