#!/pkg/bin/ksh
# ---------------------------------------------------------------------
# cem_driver_show_techsupport - Show tech-support script for cem_driver
#
# Sep 2021-22, Nikhil Shetty, Sreejith Sreekumaran, Sunny Keshri
#
# Copyright (c) 2017-2019, 2021-2022 by cisco Systems, Inc.
# All rights reserved.
#--------------------------------------------------------------------

# This script fragment contains the code for the following functions
# - print_main_heading
# - print_command_heading
# - run_single_command
# - run_commands
# - run_single_command_on_all_nodes
# - run_commands_on_all_nodes
# - default_parser_function
. /pkg/bin/show_tech_main_fragment

# List each set of show commands to be run. Each set must finish with an empty
# string. Note that it is important to use single quotes rather than double
# quotes for the strings containing your commands.

__cardtype="unspecified"

# Set the default values of the file name for which show tech-support macsec
# is to run and the file it is to write to.
# Read in the arguments to the script, setting node_required and filename
# according to these arguments.
# Note that it is important for security reasons that users can only enter
# alphanumeric filenames and nodes and that anywhere calling this script must
# enforce this.
while [ "$#" -gt "0" ]; do
    case "$1" in
        -t) __cardtype="$2"; shift 2;;
        *)  default_parser_function "$@"; shift $#;;
    esac
done

if [ "$__cardtype" == "unspecified" ]; then
    __cardtype=`node_type`
fi

 # global commands on RP


###############################################################################
# Show commands that run once per LR                                          #
###############################################################################


sys_exec[1]='show install active'
sys__ksh[1]='sdr_instcmd show install active'

sys_exec[2]='show install repository'
sys__ksh[2]='sdr_instcmd show install repository'

sys_exec[3]='show version'
sys__ksh[3]='ng_show_version'

sys_exec[4]='show platform'
sys__ksh[4]='show_platform_sysdb'

sys_exec[5]='show running-config'
sys__ksh[5]='nvgen -c -i1 -l 1 -t 1 -o 1'

sys_exec[6]='show inventory all'
sys__ksh[6]='show_inventory -e -t'

sys_exec[7]='show interfaces summary'
sys__ksh[7]='show_interface -a -o 0x3'

sys_exec[8]='show interfaces brief'
sys__ksh[8]='show_interface -a -o 0x2'

sys_exec[9]='show process cem_driver location all'
sys__ksh[9]='sysmgr_show -o -p cem_driver -n all'

sys_exec[10]='show hw-mod fpd'
sys__ksh[10]='show_fpd_loc_ng fpd'

sys_exec[11]=''
sys__ksh[11]=''

lc_exec[1]=''
lc__ksh[1]=''

t1e1_exec[1]='show t1e1 ea trace all location all'
t1e1__ksh[1]='show_t1e1_ltrace -E -A -i all'

t1e1_exec[2]='show t1e1 ma trace all location all'
t1e1__ksh[2]='show_t1e1_ltrace -M -A -i all'

t1e1_exec[3]=''
t1e1__ksh[3]=''

sonet_exec[1]='show sonet-ma trace init location all '
sonet__ksh[1]='sonet_ma_show_ltrace -B -i all'

sonet_exec[1]='show sonet-ma trace init location all '
sonet__ksh[1]='sonet_ma_show_ltrace -B -i all'

sonet_exec[2]='show sonet-ma trace info location all '
sonet__ksh[2]='sonet_ma_show_ltrace -I -i all'

sonet_exec[3]='show sonet-ma trace error location all '
sonet__ksh[3]='sonet_ma_show_ltrace -E -i all'

sonet_exec[4]='show sonet-ea trace info location all '
sonet__ksh[4]='sonet_ea_show_ltrace -I -i all'

sonet_exec[5]='show sonet-ea trace error location all '
sonet__ksh[5]='sonet_ea_show_ltrace -E -i all'

sonet_exec[6]=''
sonet__ksh[6]=''

ltrace_exec[1]='Show cem-driver ltrace all location all'
ltrace__ksh[1]='cem_driver_show_ltrace -E -V -B -i all'

ltrace_exec[2]='Show ethernet v-ether trace location all'
ltrace__ksh[2]='eth_intf_show_trace -i all'

ltrace_exec[3]='show ea-server-common ltrace all location all'
ltrace__ksh[3]='ea_server_common_show_ltrace -i all -EVB'

ltrace_exec[4]=''
ltrace__ksh[4]=''
#
# Variable used to enable admin mode commands
#
admin=0;


# Each option collect follows information.
#   -L : local plane.
#   -t : card type.
#   -A : admin + shared + local plane.
#   -S : shared + local plane.
# Notice: current 'show tech multi sysdb' doesn't collect any information
#        from SP because of memory shortage on SP.
#
while [ "$#" -gt "0" ]; do
    case "$1" in
        -A) admin=1;                    shift 1;;
        -S) shared=1;                   shift 1;;
        -L) location="$2";              shift 2;;
        -t) __cardtype="$2";            shift 2;;
        *)  default_parser_function $@; shift $#;;
    esac
done

###############################################################################
# Show controller functions                                                  #
###############################################################################
show_controllers_otu(){
    outfile=$1/otu_controllers
    echo "=================================" >> $outfile
    echo "--- show controller OTU : start ---" >> $outfile
    echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
    echo -e "\n show controller otu all \n" >> $outfile
    intf_recovered -a "OTU.*" >> $outfile
    echo "----------------------------------------" >> $outfile
    /pkg/bin/portmode_show -z all | grep -e "OTU2\>" | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers OTU2 ${rsip} pm current 15-min otn \n" >> $outfile
            show_controller_otu_pm -n OTU2${r_s_i_p} -m -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    /pkg/bin/portmode_show -z all | grep OTU2E | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers OTU2E ${rsip} pm current 15-min otn \n" >> $outfile
            show_controller_otu_pm -n OTU2E${r_s_i_p} -m -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controller OTU : End ---" >> $outfile
    echo "=================================" >> $outfile
}

show_controllers_odu(){
    outfile=$1/odu_controllers
    echo "=================================" >> $outfile
    echo "--- show controller ODU : start ---" >> $outfile
    echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
    echo -e "\n show controller odu all \n" >> $outfile
    intf_otn_odu_recovered -a "ODU.*" >> $outfile
    echo "----------------------------------------" >> $outfile
    /pkg/bin/portmode_show -z all | grep "OTU2\>" | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers ODU2 ${rsip} pm current 15-min otn pathmonitor \n" >> $outfile
            show_controller_odu_pm -n ODU2${r_s_i_p} -m -g -P >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers ODU2 ${rsip} pm current 24-hour otn pathmonitor \n" >> $outfile
            show_controller_odu_pm -n ODU2${r_s_i_p} -d -g -P >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    /pkg/bin/portmode_show -z all | grep OTU2E | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers ODU2E ${rsip} pm current 15-min otn pathmonitor \n" >> $outfile
            show_controller_odu_pm -n ODU2E${r_s_i_p} -m -g -P >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers ODU2E ${rsip} pm current 24-hour otn pathmonitor \n" >> $outfile
            show_controller_odu_pm -n ODU2E${r_s_i_p} -d -g -P >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controller ODU : End ---" >> $outfile
    echo "=================================" >> $outfile
}

show_controllers_sonet(){
    outfile=$1/sonet_controllers
    echo "=================================" >> $outfile
    echo "--- show controllers OC48 : Start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep OC48 | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e " \n show controllers OC48 ${rsip} \n" >> $outfile
            exec_sonet_ma show OC48${r_s_i_p} info >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers OC48 ${rsip} pm current 24-hour ocn \n" >> $outfile
            show_controller_oc_pm -n OC48${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controllers OC48 : End ---" >> $outfile
    echo "===================================" >> $outfile

    echo "--- show controllers OC192 : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep OC192 | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers OC192 ${rsip} \n" >> $outfile
            exec_sonet_ma show OC192${r_s_i_p} info >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e"\n show controllers OC192 ${rsip} pm current 24-hour ocn \n" >> $outfile
            show_controller_oc_pm -n OC192${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controllers OC192 : End ---" >> $outfile
    echo "====================================" >> $outfile
}

show_controllers_ethernet(){
    outfile=$1/ethernet_controllers
    echo "====================================" >> $outfile
    echo "--- show controllers GigabitEthCtrlr : Start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep 1GE | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers GigabitEthCtrlr ${rsip} \n" >> $outfile
            ethernet_show_controller -i GigabitEthCtrlr${r_s_i_p} -s oper >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers GigabitEthCtrlr ${rsip} pm current 24-hour ether \n" >> $outfile
            show_controller_ethernet_pm -n GigabitEthCtrlr${r_s_i_p} -d -e >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers GigabitEthCtrlr ${rsip} pm current 24-hour pcs \n" >> $outfile
            show_controller_ethernet_pm -n GigabitEthCtrlr${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controllers GigabitEthCtrlr : end ---" >> $outfile
    echo "==============================================" >> $outfile

    echo "--- show controllers TenGigECtrlr : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep 10GE | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers tenGigECtrlr${rsip} \n" >> $outfile
            ethernet_show_controller -i TenGigECtrlr${r_s_i_p} -s oper >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers tenGigECtrlr ${rsip} pm current 24-hour ether \n" >> $outfile
            show_controller_ethernet_pm -n TenGigECtrlr${r_s_i_p} -d -e >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers tenGigECtrlr ${rsip} pm current 24-hour pcs \n" >> $outfile
            show_controller_ethernet_pm -n TenGigECtrlr${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controllers TenGigECtrlr : End ---" >> $outfile
    echo "===========================================" >> $outfile
}

show_controllers_sdh(){
    outfile=$1/sdh_controllers
    echo "--- show controllers STM16 : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep STM16 | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers STM16 ${rsip} \n" >> $outfile
            exec_sonet_ma show STM16${r_s_i_p} info >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers STM16 ${rsip} pm current 24-hour stm \n" >> $outfile
            show_controller_stm_pm -n STM16${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controllers STM16 : end ---" >> $outfile
    echo "====================================" >> $outfile
}

show_controllers_fc(){
    outfile=$1/fc_controllers
    echo "====================================" >> $outfile
    echo "--- show controller OneGigFibreChanCtrlr : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep "Fibre Channel 1G" | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controller OneGigFibreChanCtrlr ${rsip} \n" >> $outfile
            fc_show_ctrlr info OneGigFibreChanCtrlr${r_s_i_p} >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers OneGigFibreChanCtrlr ${rsip} pm current 24-hour fec \n" >> $outfile
            show_controller_fc_pm -n OneGigFibreChanCtrlr${r_s_i_p} -d -j >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers OneGigFibreChanCtrlr ${rsip} pm current 24-hour pcs \n" >> $outfile
            show_controller_fc_pm -n OneGigFibreChanCtrlr${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controller OneGigFibreChanCtrlr: end ---" >> $outfile
    echo -e "\n ================================================ \n" >> $outfile

    echo "--- show controller TwoGigFibreChanCtrlr : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep "Fibre Channel 2G" | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controller TwoGigFibreChanCtrlr ${rsip} \n" >> $outfile
            fc_show_ctrlr info TwoGigFibreChanCtrlr${r_s_i_p} >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers TwoGigFibreChanCtrlr ${rsip} pm current 24-hour fec \n" >> $outfile
            show_controller_fc_pm -n TwoGigFibreChanCtrlr${r_s_i_p} -d -j >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers TwoGigFibreChanCtrlr ${rsip} pm current 24-hour pcs \n" >> $outfile
            show_controller_fc_pm -n TwoGigFibreChanCtrlr${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controller TwoGigFibreChanCtrlr: end ---" >> $outfile
    echo -e "\n ================================================ \n" >> $outfile

    echo "--- show controller FourGigFibreChanCtrlr : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep "Fibre Channel 4G" | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controller FourGigFibreChanCtrlr  ${rsip} \n" >> $outfile
            fc_show_ctrlr info FourGigFibreChanCtrlr${r_s_i_p} >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers FourGigFibreChanCtrlr ${rsip} pm current 24-hour fec \n" >> $outfile
            show_controller_fc_pm -n FourGigFibreChanCtrlr${r_s_i_p} -d -j >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers FourGigFibreChanCtrlr ${rsip} pm current 24-hour pcs \n" >> $outfile
            show_controller_fc_pm -n FourGigFibreChanCtrlr${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controller FourGigFibreChanCtrlr : end ---" >> $outfile
    echo -e "\n ================================================ \n" >> $outfile

    echo "--- show controller EightGigFibreChanCtrlr : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep "Fibre Channel 8G" | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controller EightGigFibreChanCtrlr  ${rsip} \n" >> $outfile
            fc_show_ctrlr info EightGigFibreChanCtrlr${r_s_i_p} >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers EightGigFibreChanCtrlr ${rsip} pm current 24-hour fec \n" >> $outfile
            show_controller_fc_pm -n EightGigFibreChanCtrlr${r_s_i_p} -d -j >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers EightGigFibreChanCtrlr ${rsip} pm current 24-hour pcs" >> $outfile
            show_controller_fc_pm -n EightGigFibreChanCtrlr${r_s_i_p} -d -g >> $outfile
            echo "" >> $outfile
            echo "----------------------------------------" >> $outfile
        done
        #show_controller_fc_pm "-n" "EightGigFibreChanCtrlr0_0_2_0" "-d" "-g"
    echo "--- show controller EightGigFibreChanCtrlr : end ---" >> $outfile
    echo -e "\n ================================================ \n" >> $outfile

    echo "--- show controller SixteenGigFibreChanCtrlr : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep "Fibre Channel 16G" | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controller SixteenGigFibreChanCtrlr  ${rsip} \n" >> $outfile
            fc_show_ctrlr info SixteenGigFibreChanCtrlr${r_s_i_p} >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers SixteenGigFibreChanCtrlr ${rsip} pm current 24-hour fec \n" >> $outfile
            show_controller_fc_pm -n SixteenGigFibreChanCtrlr${r_s_i_p} -d -j >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers SixteenGigFibreChanCtrlr ${rsip} pm current 24-hour pcs \n" >> $outfile
            show_controller_fc_pm -n SixteenGigFibreChanCtrlr${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controller SixteenGigFibreChanCtrlr : end ---" >> $outfile
    echo -e "\n ================================================ \n" >> $outfile

    echo "--- show controller ThirtyTwoGigFibreChanCtrl : start ---" >> $outfile
    /pkg/bin/portmode_show -z all | grep "Fibre Channel 32G" | while read -r x;
        do
            r_s_i_p=$(echo $x |cut -c 7-13)
            rsip=$(echo ${r_s_i_p} | sed 's/\_/\//g')
            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controller ThirtyTwoGigFibreChanCtrl ${rsip} \n" >> $outfile
            fc_show_ctrlr info ThirtyTwoGigFibreChanCtrlr${r_s_i_p} >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers ThirtyTwoGigFibreChanCtrlr ${rsip} pm current 24-hour fec \n" >> $outfile
            show_controller_fc_pm -n ThirtyTwoGigFibreChanCtrlr${r_s_i_p} -d -j >> $outfile

            echo "++++++++++++++++++++++++++++++++++++++++" >> $outfile
            echo -e "\n show controllers ThirtyTwoGigFibreChanCtrlr ${rsip} pm current 24-hour pcs \n" >> $outfile
            show_controller_fc_pm -n ThirtyTwoGigFibreChanCtrlr${r_s_i_p} -d -g >> $outfile
            echo "----------------------------------------" >> $outfile
        done
    echo "--- show controller ThirtyTwoGigFibreChanCtrl: end ---" >> $outfile
    echo "======================================================" >> $outfile
}

port_mode_controllers(){
    node_name=`uname -n`
    node_subdir=$__tar_file_directory_on_node/$node_name
    if [ ! -d "$node_subdir" ]; then
        /bin/mkdir $node_subdir
    fi
    show_controllers_otu $node_subdir
    show_controllers_odu $node_subdir
    show_controllers_sonet $node_subdir
    show_controllers_ethernet $node_subdir
    show_controllers_sdh $node_subdir
    show_controllers_fc $node_subdir
}

# Parse the arguments to the script.
# Usage:
#
#sys.exit()
# A function called display() must be provided that calls the functions to
# Print the output heading
do_show_command() {
    print_main_heading "show tech-support cemdriver"
    case "$__cardtype" in
    "SYS")
        exec_commands sys
        ;;
    "DRP"|"RP")
        exec_commands t1e1

        exec_commands sonet

        exec_commands ltrace

        port_mode_controllers
        ;;
    esac

    enable_techs "" /pkg/bin/show_tech_cem

    # Print the closing heading.
    print_main_heading "show tech-support cemdriver complete"
}
# The display function.
display() {
        do_show_command
}

  # This function calls the display() function and sends the output to file if
  # the file option has been set.
. /pkg/bin/show_tech_file_fragment
