[comp.unix.questions] FANCY BANNER

Narotham Reddy (08/18/89)

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	baner
# This archive created: Thu Aug 17 17:30:05 1989
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'baner'
then
	echo shar: "will not over-write existing file 'baner'"
else
cat << \SHAR_EOF > 'baner'
echo '
 1) Banner with "#" character     21) Banner with "H" character
 2) Banner with "$" character     22) Banner with "I" Character
 3) Banner with "%" character     23) Banner with "J" Character
 4) Banner with "^" character     24) Banner with "K" character
 5) Banner with "&" character     25) Banner with "L" Character
 6) Banner with "*" character     26) Banner with "M" Character
 7) Banner with "-" character     27) Banner with "N" Character
 8) Banner with "=" character     28) Banner with "O" Character
 9) Banner with "+" character     29) Banner with "P" Character
10) Banner with "!" character     30) Banner with "Q" Character
11) Banner with "~" character     31) Banner with "R" Character
12) Banner with "\" character     32) Banner with "S" Character
13) Banner with "/" character     33) Banner with "T" Character
14) Banner with "A" character     34) Banner with "U" Character
15) Banner with "B" character     35) Banner with "V" Character
16) Banner with "C" character     36) Banner with "W" Character
17) Banner with "D" character     37) Banner with "X" Character
18) Banner with "E" character     38) Banner with "Y" Character
19) Banner with "F" character     39) Banner with "Z" Character
20) Banner with "G" character


        Enter your choice (number 1 or 2......39 )  \007 \c'

        read choice

        echo '	Enter the string (not more than 10 chars) \007 \c'
	read string

        case $choice

        in

         1 ) banner $string | tr '#' '#' ;;
         2 ) banner $string | tr '#' '$' ;;
         3 ) banner $string | tr '#' '%' ;;
         4 ) banner $string | tr '#' '^' ;;
         5 ) banner $string | tr '#' '&' ;;
         6 ) banner $string | tr '#' '*' ;;
         7 ) banner $string | tr '#' '-' ;;
         8 ) banner $string | tr '#' '=' ;;
         9 ) banner $string | tr '#' '+' ;;
        10 ) banner $string | tr '#' '!' ;;
        11 ) banner $string | tr '#' '~' ;;
        12 ) banner $string | tr '#' '\\' ;;
        13 ) banner $string | tr '#' '/' ;;
        14 ) banner $string | tr '#' 'A' ;;
        15 ) banner $string | tr '#' 'B' ;;
        16 ) banner $string | tr '#' 'C' ;;
        17 ) banner $string | tr '#' 'D' ;;
        18 ) banner $string | tr '#' 'E' ;;
        19 ) banner $string | tr '#' 'F' ;;
        20 ) banner $string | tr '#' 'G' ;;
        21 ) banner $string | tr '#' 'H' ;;
        22 ) banner $string | tr '#' 'I' ;;
        23 ) banner $string | tr '#' 'J' ;;
        24 ) banner $string | tr '#' 'K' ;;
        25 ) banner $string | tr '#' 'L' ;;
        26 ) banner $string | tr '#' 'M' ;;
        27 ) banner $string | tr '#' 'N' ;;
        28 ) banner $string | tr '#' 'O' ;;
        29 ) banner $string | tr '#' 'P' ;;
        30 ) banner $string | tr '#' 'Q' ;;
        31 ) banner $string | tr '#' 'R' ;;
        32 ) banner $string | tr '#' 'S' ;;
        33 ) banner $string | tr '#' 'T' ;;
        34 ) banner $string | tr '#' 'U' ;;
        35 ) banner $string | tr '#' 'V' ;;
        36 ) banner $string | tr '#' 'W' ;;
        37 ) banner $string | tr '#' 'X' ;;
        38 ) banner $string | tr '#' 'Y' ;;
        39 ) banner $string | tr '#' 'Z' ;;

         * ) echo "Illegal option" ;;

        esac



SHAR_EOF
chmod +x 'baner'
fi
exit 0
#	End of shell archive

decot@hpisod2.HP.COM (Dave Decot) (08/19/89)

Hey, that's a good comp.unix.question.

The answer is:

    banner "$2" | tr "#" "$1"

Dave Decot
HP

bruce@idsssd.UUCP (Bruce T. Harvey) (08/21/89)

In article <10650068@hpisod2.HP.COM>, decot@hpisod2.HP.COM (Dave Decot) writes:
> Hey, that's a good comp.unix.question.
> 
> The answer is:
> 
>     banner "$2" | tr "#" "$1"
> 
> Dave Decot
> HP

And, for all you folks that use banner to produce more than one line of
output display at a time:

MYvar=$1
shift
banner "$*" | tr "#" "$MYvar"

woods@cbnewsc.ATT.COM (Warren D. Swan) (08/24/89)

In article <730@idsssd.UUCP> bruce@idsssd.UUCP (Bruce T. Harvey) writes:
>In article <10650068@hpisod2.HP.COM>, decot@hpisod2.HP.COM (Dave Decot) writes:
>> Hey, that's a good comp.unix.question.
>> ...
>
>And, for all you folks that use banner to produce more than one line of
>output display at a time:
>
>MYvar=$1
>shift
>banner "$*" | tr "#" "$MYvar"

Excellent.  For the sake of discussion, we'll call this script: sign.

Just change the "$*" to "$@" and it'll behave even more like
a spiffed up version of banner.

(Do you see the difference?  If we left it as banner "$*"
[thanks for using the quotes, most people seem to forget them], then:

    sign @ "This is" "3 lines" "of info."

would cause output like:

    banner "This is 3 lines of info."

with the #s replaced by @s, thusly:

@@@@@@@                                                          @@@@@
   @     @    @     @     @@@@              @     @@@@          @     @
   @     @    @     @    @                  @    @                    @
   @     @@@@@@     @     @@@@              @     @@@@           @@@@@
   @     @    @     @         @             @         @               @
   @     @    @     @    @    @             @    @    @         @     @
   @     @    @     @     @@@@              @     @@@@           @@@@@

INSTEAD OF what was originally intended:

    banner "This is" "3 lines" "of info."

with the #s replaced by @s, which I won't reproduce here.  Other than that,
Good idea!)

Warren D. Swan  (WooDS)     Y n n ____ __      You can't tell which way a train
AT&T Bell Laboratories     -(((((([__]/__]     went by looking at the tracks.
Naperville, Illinois       /o-OOOOO~~  oo
att!cblph!woods         #####################  FRISCO 1630 Decapod (2-10-0) IRM