Advertisement
Advertisement
| 03.17.2008 at 07:57AM PDT, ID: 23247204 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: |
##!/usr/bash
# env.sh
set -x
# DETAILED DESCRIPTION AND USAGE
# ====================================================================================================|
# DESCRIPTION FUNCTION
# --------------------------------------------------------------------------------------------------|
pvt_description() {
sb \
"^PROGRAM DESCRIPTION: 'automationenv'
^--------------------------------------------------------------------------------
^ Configuration Management Korn Shell Environment Configuration Script.
^ 'automationenv' is executed during the initialization of all new Korn shell
^ processes in the CMA Environment. This behavior is set by 'automationprofile'
^ when it sets the value of the 'ENV' environment variable.
^
^ 'automationenv' configures all common shell aliases and shell functions used
^ by the various programs that make up the CM Automation. These include common
^ command aliases and utility functions used by the other programs. Functions
^ comprising the environment's on-line documentation are among these.
^
^ There is rarely a need for operators to manually execute 'automationenv' since
^ the shell program runs it automatically.
^
^$(pvt_syntax)
^$(pvt_usage)"
# Return success
return 0
}
# SYNTAX EXAMPLE FUNCTION
# --------------------------------------------------------------------------------------------------|
pvt_syntax() {
sb -i2 -n -x \
"^SYNTAX: 'automationenv'
^------------------------------------------------------------------------------
^ $(pvt_syntax_one_line)
^ Available options include:
^ -h ..... Display this description
^ -q ..... Enable quiet mode
"
# Return success
return 0
}
# ONE-LINE SYNTAX EXAMPLE
# --------------------------------------------------------------------------------------------------|
pvt_syntax_one_line() {
B "SYNTAX: 'automationenv' -[hq]"
# Return success
return 0
}
# USAGE FUNCTION
# --------------------------------------------------------------------------------------------------|
pvt_usage() {
sb -i2 -n -x \
"^USAGE INSTRUCTIONS: 'automationenv'
^------------------------------------------------------------------------------
^ There is normally no need to explicitly use this program.
^ If desired, however, use the shell syntax '. automationenv [-hq]' to execute
^ in the context of your current shell environment.
"
# Return success
return 0
}
# FUNCTION DEFINITIONS
# ====================================================================================================|
function message {
# CONFIGURE CONSTANTS
MSG_IFSBACKUP="$IFS"
MSG_NEWLINE='
'
# CONFIGURE OPTION DEFAULTS
MSG_LOGFILE=""
MSG_TARGET="3"
MSG_FORMAT="a"
MSG_HEADER=""
MSG_BODY=""
MSG_FOOTER=""
MSG_IND=""
MSG_EN_NEWLINE="true"
MSG_EN_DDATES="true"
MSG_EN_DCODES="true"
MSG_EN_DEC="true"
MSG_1DEC_ONLY="false"
MSG_2DEC_ONLY="false"
# PRESERVE SHELL OPTION INDEX ( ALL SHELL FUNCTIONS USING GETOPTS MUST )
MSG_OPTIND="$OPTIND"
# PROCESS OPERATOR OPTIONS AND ARGUMENTS ( UNIX COMMAND SYNTAX STANDARDS COMPLIANCE, INTRO MANUAL )
# USE GETOPTS TO PRE-PARSE OPERATOR OPTIONS AND ARGUMENTS, THEN ACT ON THEM
OPTIND=1 ; while getopts l:t:o:h:b:f:i:mndyx12 MSG_OPTCHAR
do
# Recognize option character and react appropriately
case "$MSG_OPTCHAR" in
l ) MSG_LOGFILE="$OPTARG" ;;
t ) MSG_TARGET="$OPTARG" ;;
o ) MSG_FORMAT="$OPTARG" ;;
# ** Message header?
h ) MSG_HEADER="$OPTARG" ;;
# ** Message body?
b ) MSG_BODY="$OPTARG" ;;
# ** Message footer
f ) MSG_FOOTER="$OPTARG" ;;
# ** Message indent?
i )
# *** Build the message indentation string
MSG_I="0"
while [[ "$MSG_I" -lt "$OPTARG" ]]
do
MSG_IND="${MSG_IND} " ; (( MSG_I = MSG_I + 1 ))
done
;;
# ** Disable trailing newline ( Only if allowed )?
m ) if [[ "$CM_MSG_ENFORCE_TNL" != 'true' ]] ; then MSG_NONL="-n" ; fi ;;
# ** Disable declation newline?
n ) MSG_EN_NEWLINE="false" ;;
# ** Disable declaration dates?
d ) MSG_EN_DDATES="false" ;;
# ** Disable declaration format codes?
y ) MSG_EN_DCODES="false" ;;
# ** Disable declaration?
x ) MSG_EN_DEC="false" ;;
# ** Generate stand-alone start-declaration?
1 ) MSG_1DEC_ONLY="true" ;;
# ** Generate stand-alone end-declaration?
2 ) MSG_2DEC_ONLY="true" ;;
# ** Missing required option argument?
? )
# *** Error
printf -u2
printf -u2 - "-(================================= ERROR ======================================"
printf -u2 - "AUTOMATIONENV.MESSAGE(): MISSING OPTION ARGUMENT:"
printf -u2 -
printf -u2 - "Correct the syntax and try again."
printf -u2 -
printf -u2 - "message -l:LOGFILE"
printf -u2 - "message -t1|2|3 -oa|A|b|B [-h:]HEADER [-b:]BODY [-f:]FOOTER -1:INDENT -n"
printf -u2 - " -d -y -x -1 -2"
printf -u2 - "==============================================================================)-"
# *** Cleanup and return
OPTIND="$MSG_OPTIND" ; unset_private -q -k 'MSG_' ; return 255
;;
esac # Recognize flag and react appropriately
done # USE GETOPTS TO PRE-PARSE OPERATOR OPTIONS AND ARGUMENTS, THEN ACT ON THEM
# RESTORE FORMER SHELL OPTION INDEX
OPTIND="$MSG_OPTIND"
# RETRIEVE FREE-FORM MESSAGE ARGUMENTS
# * Prepare a counter to limit number of message text arguments
MSG_COUNT="0"
# * Re-parse arguments for free-form message text ( no leading hyphen )
for MSG_ARGUMENT
do
# ** Verify non-flagged argument and allocate text appropriately
if [[ "$MSG_ARGUMENT" != -* ]]
then
# *** Verify message count has not been exceeded prior to text allocation
if [[ "$MSG_COUNT" -lt "3" ]]
then
# **** Allocate
case "$MSG_COUNT" in
0 ) MSG_HEADER="$MSG_ARGUMENT" ;;
1 ) MSG_BODY="$MSG_ARGUMENT" ;;
2 ) MSG_FOOTER="$MSG_ARGUMENT" ;;
esac
(( MSG_COUNT = MSG_COUNT + 1 ))
else
# **** Error
print -u2
print -u2 - "-(================================= ERROR ======================================"
print -u2 - "AUTOMATIONENV.MESSAGE(): UNRECOGNIZED ARGUMENT:"
print -u2 -
print -u2 - "Correct the syntax and try again."
print -u2 - " Argument: '$MSG_ARGUMENT'"
print -u2 -
print -u2 - "message -l:LOGFILE"
print -u2 - "message -t1|2|3 -oa|A|b|B [-h:]HEADER [-b:]BODY [-f:]FOOTER -1:INDENT -n"
print -u2 - " -d -y -x -1 -2"
print -u2 - "==============================================================================)-"
# **** Cleanup and return
unset_private -q -k 'MSG_' ; return 255
fi
fi
done
# CONFIGURE SESSION LOG FILE IF APPLICABLE
# * Check for log file option/argument
if [[ ! -z "$MSG_LOGFILE" ]]
then
# ** Verify the new logfile is accessable
touch "$MSG_LOGFILE"
if [[ "$?" -ne '0' ]]
then
# *** Throw exception
print -u2
print -u2 - "-(================================= ERROR ======================================"
print -u2 - "AUTOMATIONENV.MESSAGE(): INVALID LOGFILE:"
print -u2 -
print -u2 - "Cannot create or access the logfile."
print -u2 - " File: '$MSG_LOGFILE'"
print -u2 -
print -u2 - "message -l:LOGFILE"
print -u2 - "message -t1|2|3 -oa|A|b|B [-h:]HEADER [-b:]BODY [-f:]FOOTER -1:INDENT -n"
print -u2 - " -d -y -x -1 -2"
print -u2 - "==============================================================================)-"
# *** Cleanup and return
unset_private -q -k 'MSG_' ; return 255
fi
# ** Configure logfile security
chmod 777 "$MSG_LOGFILE"
# ** Export the new configuration
export CM_MSG_LOGFILE="$MSG_LOGFILE"
# ** Cleanup and return success
unset_private -q -k 'MSG_' ; return 0
fi
# ASSEMBLE MESSAGE DECLARATIONS IF APPLICABLE
if "$MSG_EN_DEC"
then
# * Prepare declarations based on messsage format and declaration options
case "$MSG_FORMAT" in
# ** Standard banner?
a )
# *** Logfile declaration
MSG_DECB_L="-(========================"
MSG_DECB_R="=========================="
if "$MSG_EN_DCODES" && "$MSG_EN_DDATES"
then
MSG_DECB_M="============================"
elif [[ "$MSG_EN_DCODES" != 'true' ]] && "$MSG_EN_DDATES"
then
MSG_DECB_M="============================"
elif "$MSG_EN_DCODES" && [[ "$MSG_EN_DDATES" != 'true' ]]
then
MSG_DECB_M="============================"
elif [[ "$MSG_EN_DCODES" != 'true' ]] && [[ "$MSG_EN_DDATES" != 'true' ]]
then
MSG_DECB_M="============================"
fi
MSG_DECB="${MSG_DECB_L}${MSG_DECB_M}${MSG_DECB_R}"
# *** Terminal declaration
if "$MSG_EN_DCODES"
then
MSG_DECB_X="-(=============================================================================="
else
MSG_DECB_X="-(=============================================================================="
fi
;;
# ** Standard line?
A )
# *** Logfile declaration
case "$MSG_EN_DCODES" in
true )
if [[ ! -z "$MSG_HEADER" ]]
then MSG_DECS_L="-( "
else MSG_DECS_L="-("
fi
;;
false ) MSG_DECS_L="-( " ;;
esac
case "$MSG_EN_DDATES" in
true ) MSG_DECS_R="" ;;
false ) MSG_DECS_R="" ;;
esac
MSG_DECS="${MSG_DECS_L}${MSG_DECS_R}"
# *** Terminal declaration
MSG_DECS_X="$MSG_DECS_L"
;;
# ** Warning banner?
b )
# *** Logfile declaration
MSG_DECB_L="-(========================"
MSG_DECB_R="=========================="
if "$MSG_EN_DCODES" && "$MSG_EN_DDATES"
then
MSG_DECB_M="========= WARNING! ========="
elif [[ "$MSG_EN_DCODES" != 'true' ]] && "$MSG_EN_DDATES"
then
MSG_DECB_M="============================"
elif "$MSG_EN_DCODES" && [[ "$MSG_EN_DDATES" != 'true' ]]
then
MSG_DECB_M="========= WARNING! ========="
elif [[ "$MSG_EN_DCODES" != 'true' ]] && [[ "$MSG_EN_DDATES" != 'true' ]]
then
MSG_DECB_M="============================"
fi
MSG_DECB="${MSG_DECB_L}${MSG_DECB_M}${MSG_DECB_R}"
# *** Terminal declaration
if "$MSG_EN_DCODES"
then
MSG_DECB_X="-(================================ WARNING! ===================================="
else
MSG_DECB_X="-(=============================================================================="
fi
;;
# ** Warning line?
B )
# *** Logfile declaration
case "$MSG_EN_DCODES" in
true )
if [[ ! -z "$MSG_HEADER" ]]
then MSG_DECS_L="-( WARNING! "
else MSG_DECS_L="-( WARNING!"
fi
;;
false ) MSG_DECS_L="-( " ;;
esac
case "$MSG_EN_DDATES" in
true ) MSG_DECS_R="" ;;
false ) MSG_DECS_R="" ;;
esac
MSG_DECS="${MSG_DECS_L}${MSG_DECS_R}"
# *** Terminal declaration
MSG_DECS_X="$MSG_DECS_L"
;;
# ** Error banner?
c )
# *** Logfile declaration
MSG_DECB_L="-(========================"
MSG_DECB_R="=========================="
if "$MSG_EN_DCODES" && "$MSG_EN_DDATES"
then
MSG_DECB_M="========== ERROR! =========="
elif [[ "$MSG_EN_DCODES" != 'true' ]] && "$MSG_EN_DDATES"
then
MSG_DECB_M="============================"
elif "$MSG_EN_DCODES" && [[ "$MSG_EN_DDATES" != 'true' ]]
then
MSG_DECB_M="========== ERROR! =========="
elif [[ "$MSG_EN_DCODES" != 'true' ]] && [[ "$MSG_EN_DDATES" != 'true' ]]
then
MSG_DECB_M="============================"
fi
MSG_DECB="${MSG_DECB_L}${MSG_DECB_M}${MSG_DECB_R}"
# *** Terminal declaration
if "$MSG_EN_DCODES"
then
MSG_DECB_X="-(================================= ERROR! ====================================="
else
MSG_DECB_X="-(=============================================================================="
fi
;;
# ** Error line?
C )
# *** Logfile declaration
case "$MSG_EN_DCODES" in
true )
if [[ ! -z "$MSG_HEADER" ]]
then MSG_DECS_L="-( ERROR! "
else MSG_DECS_L="-( ERROR!"
fi
;;
false ) MSG_DECS_L="-( " ;;
esac
case "$MSG_EN_DDATES" in
true ) MSG_DECS_R="" ;;
false ) MSG_DECS_R="" ;;
esac
MSG_DECS="${MSG_DECS_L}${MSG_DECS_R}"
# *** Terminal declaration
MSG_DECS_X="$MSG_DECS_L"
;;
esac # Prepare declarations based on messsage format and declaration options
fi # PREPARE MESSAGE DECLARATIONS IF APPLICABLE
# PROCESS LINE INDENTATION FOR MULTILINE BANNER MESSAGES
case "$MSG_FORMAT" in
a|b|c )
# * Configure shell IFS
IFS="$MSG_NEWLINE"
# * Parse message header
MSG_TEMP=''
for MSG_LINE in $MSG_HEADER
do
# ** Remove quoted indentation
MSG_LINE="${MSG_LINE#*^}"
# ** Add indentation
MSG_LINE="$MSG_IND$MSG_LINE"
# ** Append to replacement
if [[ ! -z "$MSG_TEMP" ]]
then MSG_TEMP="$MSG_TEMP$MSG_NEWLINE$MSG_LINE"
else MSG_TEMP="$MSG_LINE"
fi
done
# * Replace original message header
MSG_HEADER="$MSG_TEMP"
# * Parse message body
MSG_TEMP=''
for MSG_LINE in $MSG_BODY
do
# ** Remove quoted indentation
MSG_LINE="${MSG_LINE#*^}"
# ** Add indentation
MSG_LINE="$MSG_IND$MSG_LINE"
# ** Append to replacement
if [[ ! -z "$MSG_TEMP" ]]
then MSG_TEMP="$MSG_TEMP$MSG_NEWLINE$MSG_LINE"
else MSG_TEMP="$MSG_LINE"
fi
done
# * Replace original message body
MSG_BODY="$MSG_TEMP"
# * Parse message footer
MSG_TEMP=''
for MSG_LINE in $MSG_FOOTER
do
# ** Remove quoted indentation
MSG_LINE="${MSG_LINE#*^}"
# ** Add indentation
MSG_LINE="$MSG_IND$MSG_LINE"
# ** Append to replacement
if [[ ! -z "$MSG_TEMP" ]]
then MSG_TEMP="$MSG_TEMP$MSG_NEWLINE$MSG_LINE"
else MSG_TEMP="$MSG_LINE"
fi
done
# * Replace original message footer
MSG_FOOTER="$MSG_TEMP"
;;
esac
# ASSEMBLE MESSAGE TEXT IF APPLICABLE
if [[ "$MSG_1DEC_ONLY" != 'true' ]] && [[ "$MSG_2DEC_ONLY" != 'true' ]]
then
# ** Check for banner vs. line formats and prepare text accordingly
case "$MSG_FORMAT" in
# *** Banner formats
a|b|c )
# **** Shorten newline name
MSG_NL="$MSG_NEWLINE"
# **** Prepare remaining message components
if [[ ! -z "$MSG_HEADER" ]] && [[ ! -z "$MSG_BODY" ]] ; then MSG_HBS=":$MSG_NL$MSG_NL" ; fi
if [[ ! -z "$MSG_BODY" ]] && [[ ! -z "$MSG_FOOTER" ]] ; then MSG_BFS="$MSG_NL$MSG_NL" ; fi
# **** Assemble all message components
MSG_TEXT="$MSG_HEADER$MSG_HBS$MSG_BODY$MSG_BFS$MSG_FOOTER"
;;
# *** Line formats
A|B|C )
# **** Prepare remaining message components
if [[ ! -z "$MSG_HEADER" ]] && [[ ! -z "$MSG_BODY" ]] ; then MSG_HBS=": " ; fi
if [[ ! -z "$MSG_BODY" ]] && [[ ! -z "$MSG_FOOTER" ]] ; then MSG_BFS=": " ; fi
# **** Assemble all message components
MSG_TEXT="$MSG_HEADER$MSG_HBS$MSG_BODY$MSG_BFS$MSG_FOOTER"
;;
esac
fi # ASSEMBLE MESSAGE TEXT IF APPLICABLE
# USE REQUESTED STAND-ALONE DECLARATION IN PLACE OF MESSAGE TEXT IF APPLICABLE
if "$MSG_1DEC_ONLY"
then
case "$MSG_FORMAT" in
a|b|c ) MSG_FINAL="$MSG_DECB_X" ;;
A|B|C ) MSG_FINAL="$MSG_DECS_X" ;;
esac
fi
if "$MSG_2DEC_ONLY"
then
case "$MSG_FORMAT" in
a|b|c )
MSG_FINAL="==============================================================================)-"
;;
A|B|C )
MSG_FINAL=")-"
;;
esac
fi
# OUTPUT MESSAGE TO LOGFILE WITH DECLARATIONS IF APPLICABLE
case "$MSG_TARGET" in
2|3 )
# * Complete message assembly if applicable
if [[ "$MSG_1DEC_ONLY" != 'true' ]] && [[ "$MSG_2DEC_ONLY" != 'true' ]]
then
# ** Perform final message build
case "$MSG_FORMAT" in
a|b|c ) # *** Banners
# **** Prepare remaining components
if "$MSG_EN_NEWLINE"
then MSG_BNL="$MSG_NEWLINE"
else MSG_BNL=""
fi
if "$MSG_EN_DEC"
then
MSG_DECB_E="==============================================================================)-"
else
MSG_DECB_E=""
fi
# **** Complete assembly
case "$MSG_EN_DEC" in
true ) MSG_FINAL="$MSG_BNL$MSG_IND$MSG_DECB_X$MSG_NL$MSG_TEXT$MSG_NL$MSG_IND$MSG_DECB_E" ;;
false ) MSG_FINAL="$MSG_BNL$MSG_TEXT" ;;
esac
;;
A|B|C ) # *** Lines
# **** Prepare remaining components
if "$MSG_EN_DEC"
then MSG_DECS_E=" )-"
else MSG_DECS_E=""
fi
# **** Complete assembly
case "$MSG_EN_DEC" in
true ) MSG_FINAL="$MSG_BNL$MSG_IND$MSG_DECB_X$MSG_NL$MSG_TEXT$MSG_NL$MSG_IND$MSG_DECB_E" ;;
false ) MSG_FINAL="$MSG_TEXT" ;;
esac
;;
esac # ** Perform final message build
fi # * Complete message assembly if applicable
# * Output completed message text to logfile
if [[ ! -z "$CM_MSG_LOGFILE" ]]
then
print $MSG_NONL - "$MSG_FINAL" >> "$CM_MSG_LOGFILE"
fi
;;
esac # OUTPUT MESSAGE TO LOGFILE WITH DECLARATIONS IF APPLICABLE
# OUTPUT MESSAGE TO TERMINAL WITH DECLARATIONS IF APPLICABLE
# * Complete message assembly if applicable
case "$MSG_TARGET" in
1|3 )
# * Complete message assembly if applicable
if [[ "$MSG_1DEC_ONLY" != 'true' ]] && [[ "$MSG_2DEC_ONLY" != 'true' ]]
then
# ** Perform final message build
case "$MSG_FORMAT" in
a|b|c ) # *** Banners
# **** Prepare remaining components
if "$MSG_EN_NEWLINE"
then MSG_BNL="$MSG_NEWLINE"
else MSG_BNL=""
fi
if "$MSG_EN_DEC"
then
MSG_DECB_E="==============================================================================)-"
else
MSG_DECB_E=""
fi
# **** Complete assembly
case "$MSG_EN_DEC" in
true ) MSG_FINAL="$MSG_BNL$MSG_IND$MSG_DECB_X$MSG_NL$MSG_TEXT$MSG_NL$MSG_IND$MSG_DECB_E" ;;
false ) MSG_FINAL="$MSG_BNL$MSG_TEXT" ;;
esac
;;
A|B|C ) # *** Lines
# **** Prepare remaining components
if "$MSG_EN_DEC"
then MSG_DECS_E=" )-"
else MSG_DECS_E=""
fi
# **** Complete assembly
MSG_FINAL="$MSG_IND$MSG_DECS_X$MSG_TEXT$MSG_DECS_E"
;;
esac # ** Perform final message build
fi # * Complete message assembly if applicable
# * Output completed message text to terminal
case "$MSG_FORMAT" in # ** Check standard vs. error output
a|A|b|B ) print $MSG_NONL -u1 - "$MSG_FINAL" ;;
c|C ) print $MSG_NONL -u2 - "$MSG_FINAL" ;;
esac
;;
esac # OUTPUT MESSAGE TO TERMINAL WITH DECLARATIONS IF APPLICABLE
# CLEANUP AND RETURN SUCCESS
# * Restore shell IFS
IFS="$MSG_IFSBACKUP"
# * Manually unset MSG_FINAL since it exceeds unset_private capability
unset MSG_FINAL
# * Return
unset_private -q -k 'MSG_' ; return 0
} ; typeset -xf message # MESSAGE()
# Session Log Selection
logfile() {
message -l"$1"
}
# Banner replacements for 'echo' and 'print'
alias t='message -n -oa -t1 --'
alias l='message -n -oa -t2 --'
alias b='message -n -oa -t3 --'
# One-line replacements for 'echo' and 'print'
alias T='message -d -n -oA -t1 -x --'
alias L='message -d -n -oA -t2 -x --'
alias B='message -d -n -oA -t3 -x --'
# Stand-alone banner declarations
alias d1st='message -oa -t1 -1 -n --'
alias d1sl='message -oa -t2 -1 -n --'
alias d1sb='message -oa -t3 -1 -n --'
alias d2st='message -oa -t1 -2 -n --'
alias d2sl='message -oa -t2 -2 -n --'
alias d2sb='message -oa -t3 -2 -n --'
alias d1wt='message -ob -t1 -1 -n --'
alias d1wl='message -ob -t2 -1 -n --'
alias d1wb='message -ob -t3 -1 -n --'
alias d2wt='message -ob -t1 -2 -n --'
alias d2wl='message -ob -t2 -2 -n --'
alias d2wb='message -ob -t3 -2 -n --'
alias d1et='message -oc -t1 -1 -n --'
alias d1el='message -oc -t2 -1 -n --'
alias d1eb='message -oc -t3 -1 -n --'
alias d2et='message -oc -t1 -2 -n --'
alias d2el='message -oc -t2 -2 -n --'
alias d2eb='message -oc -t3 -2 -n --'
# Standard Banners
alias st='message -oa -t1'
alias sl='message -oa -t2'
alias sb='message -oa -t3'
# Standard One-Liners
alias ST='message -oA -t1'
alias SL='message -oA -t2'
alias SB='message -oA -t3'
# Warning Banners
alias wt='message -ob -t1'
alias wl='message -ob -t2'
alias wb='message -ob -t3'
# Warning One-Liners
alias WT='message -oB -t1'
alias WL='message -oB -t2'
alias WB='message -oB -t3'
# Error Banners
alias et='message -oc -t1'
alias el='message -oc -t2'
alias eb='message -oc -t3'
# Error One-Liners
alias ET='message -oC -t1'
alias EL='message -oC -t2'
alias EB='message -oC -t3'
alias
wb
eb
sb
tb
--------------------------------------------------------------------------------------------------|
display_env_menu() {
# BACKUP AND PREPARE INTERNAL FIELD SEPERATORS
DEM_IFSBACKUP="$IFS"
DEM_IFSCOMMASPACE=', '
DEM_IFSNEWLINE='
'
# PREPARE FILTERING REGULAR EXPRESSION
SPC_RE='^CM_|^CME_|^PVCS_'
if [[ ! -z "$1" ]] ; then SPC_RE="$1" ; fi
# RETRIEVE AND FILTER ENVIRONMENT DATA INTO ENVIRONMENT LIST
# Build the initial list
DEM_ENVLIST="$( print "$(env)" | awk "{ if( \$1 ~ /$SPC_RE/ ) print \$1 }" FS="$CM_FS_EQUALS" )"
# THROW EXCEPTION IF THE ENVIRONMENT LIST IS ZERO LENGTH
if [[ -z "$DEM_ENVLIST" ]]
then
# Throw exception
wb "AUTOMATIONENV.DISPLAY_ENV_MENU()" "THE ENVIRONMENT DOES NOT CONTAIN MATCHING VARIABLES"
return 255
fi
# SORT AND ADD INDEX NUMBERS TO THE LIST
DEM_ENVLIST="$( print "$DEM_ENVLIST" | sort -f | nawk '{ print NR ": " $0 }' )"
# INTERACTIVELY PROMPT OPERATOR UNTIL EXIT COMMAND IS ISSUED
while [[ "$DEM_RESPONSE" != 'X' ]] && [[ "$DEM_RESPONSE" != 'x' ]]
do
# Display prompt header on clear display
clear
st -x \
"^$( d1st )
^AUTOMATIONENV.DISPLAY_ENV_MENU(): ENVIRONMENT REVIEW FOR '$SPC_RE'
^--------------------------------------------------------------------------------
^
^ENVIRONMENT SELECTION LIST:"
# Print indexed environment list with proper indent
st -i2 -n -x "$DEM_ENVLIST" | more
# Obtain a valid operator response
DEM_VALIDRESPONSE='NO'
while [[ "$DEM_VALIDRESPONSE" = 'NO' ]]
do
# Obtain a new response
T
ST -m -x -- " -> Enter your selections, 'h' for help, or 'x' to exit: "
read DEM_RESPONSE
T " <- Operator entered '$DEM_RESPONSE'"
# Verify response and prepare validated response if applicable
case "$DEM_RESPONSE" in
'h' | 'H' )
DEM_VALIDRESPONSE="------------------------------------------------------------------------------
^Your expression is compared to the characters before the first colon in the
^form of /^x/ where you supply 'x'. Some general examples follow:
^ Selection 15: .................... 15
^ Selections 15, 16 and 20: ........ 15,16,20
^ Selections 1-5: .................. [1-5]
^ Selections 1-5 and 7-9: .......... ([1-5]|[7-9])
^ Selections 11-17: ................ 1[1-7]
^ All Selections: ................. .*
^------------------------------------------------------------------------------"
;;
'x' | 'X' )
# Prepare validated exit response
DEM_VALIDRESPONSE='-( Exiting At Operator Request )-'
;;
'' )
DEM_VALIDRESPONSE='NO'
;;
* )
# Attempt to prepare validated response if possible
# ** Prepare a regular expression based on the operator selection list (no trailing '|')
IFS="$DEM_IFSCOMMASPACE"
DEM_SRE='' ; for DEM_S in $DEM_RESPONSE; do DEM_SRE="$DEM_SRE^$DEM_S:|"; done
DEM_SRE="${DEM_SRE%\|}"
# ** Attempt to generate response ( Note mixed shell quoting in nawk expression )
DEM_ATTEMPT="$( print "$DEM_ENVLIST" | awk "
{ if( \$1 ~ /$DEM_SRE/ )"'{ print $1 " " $2 "=\047" ENVIRON[$2] "\047" }}' )"
# ** Verify attempt and enable as valid response if possible
if [[ ! -z "$DEM_ATTEMPT" ]] ; then DEM_VALIDRESPONSE="$DEM_ATTEMPT" ; fi
;;
esac # Verify response and prepare validated response if applicable
done # Obtain a valid operator response
# Display validated operator response
st -i2 -n -x \
"^
^$DEM_VALIDRESPONSE
^" | more
# Prompt to save output if applicable
if ( [[ "$DEM_RESPONSE" != "x" ]] && [[ "$DEM_RESPONSE" != "X" ]] )
then
ST -m -x -- " -> Enter 'y' to save or press ENTER to continue... "
read DEM_RESPONSE2
if [[ "$DEM_RESPONSE2" = "y" ]] || [[ "$DEM_RESPONSE2" = "Y" ]]
then
DEM_FILENAME="./display_env_menu.$( date +%Y%m%d_%H:%M:%S).out"
T -i2 "$DEM_VALIDRESPONSE" > "$DEM_FILENAME"
T " -( WROTE FILE '$DEM_FILENAME' )-"
T " -> Press ENTER to continue... "
read DEM_NULL
fi
fi # Prompt to save output if applicable
done # INTERACTIVELY PROMPT OPERATOR UNTIL EXIT COMMAND IS ISSUED
# UNSET FUNCTION PRIVATE VARIABLES AND RESTORE DEFAULT IFS
IFS="$DEM_IFSBACKUP"
unset_private -q -k 'DEM_'
d2st
}
typeset -xf display_env_menu
# HEADER CODE
# ====================================================================================================|
# --------------------------------------------------------------------------------------------------|
# BODY CODE
# ====================================================================================================|
# EXECUTE EXTENSION ENVIRONMENT SCRIPTS
# --------------------------------------------------------------------------------------------------|
IFS=','
for PVT_XENV in $CM_XENVS
do
if [[ ! -z "$PVT_XENV" ]]
then . "$PVT_XENV"
fi
done
IFS="$CM_IFSDEFAULT"
# FOOTER CODE
# ====================================================================================================|
# RETURN SUCCESS
# --------------------------------------------------------------------------------------------------|
# return 0
|