Sponsored Content
The Lounge What is on Your Mind? Merry Xmas (special present inside) Post 303009984 by bakunin on Saturday 23rd of December 2017 10:21:10 PM
Old 12-23-2017
Merry Xmas (special present inside)

A Merry Xmas to all of you.

And, as a special present to vbe (he knows why) a little exercise:

Code:
#! /bin/ksh

pPrintSnow ()
{
typeset -i iLen=$1
while (( iLen )) ; do
     if ! (( RANDOM % 31 )) ; then
          printf "%1s" "."
     else
          printf "%1s" " "
     fi
     (( iLen -= 1 ))
done
return 0
}



pPrintTreeLine ()
{
typeset -i iWidth=$1
typeset -i iTermWidth=$COLUMNS
typeset -i iOffset=$(( (iTermWidth - iWidth)/2 ))

pPrintSnow $iOffset
while [ $iWidth -gt 0 ] ; do
     if !   (( RANDOM % 11 )) ; then
          printf "%s" "$(tput sgr0;tput bold)i$(tput sgr0;tput dim)"
     elif ! (( RANDOM %  7 )) ; then
          printf "%s" "O"
     elif ! (( RANDOM % 13 )) ; then
          printf "%s" "O"
     else
          printf "%s" "*"
     fi
     (( iWidth -= 1 ))
done
pPrintSnow $iOffset
printf "\n"

return 0
}



pPrintTrunk ()
{
typeset -i iTrunkWidth=$(( $1 - 2 ))
typeset -i iTrunkHeight=$2
typeset -i iTermWidth=$COLUMNS
typeset -i iOffset=$(( (iTermWidth - iTrunkWidth)/2 ))
typeset -i iCnt=0

if [ $iTrunkWidth -lt 1 ] ; then
     (( iTrunkWidth = 1 ))
     (( iOffset = (iTermWidth - iTrunkWidth ) / 2 ))
fi

while (( iTrunkHeight )) ; do
     if (( iTrunkHeight == 1 )) ; then
          printf "%${iOffset}s/" " "
     else
          printf "%${iOffset}s " " "
     fi
     (( iCnt = iTrunkWidth ))
     while (( iCnt )) ; do
          printf "%s" "|"
          (( iCnt -= 1 ))
     done
     if (( iTrunkHeight == 1 )) ; then
          printf '\\ \n'
     else
          printf '\n'
     fi
     (( iTrunkHeight -= 1 ))
done
return 0
}



# main ()
typeset -i iHeight=$1
typeset -i iCnt=0

eval $(resize)
tput dim
(( iCnt = 1 ))
while [ $iCnt -le $(( iHeight *2 )) ] ; do
     pPrintTreeLine $iCnt
     (( iCnt += 2 ))
done
pPrintTrunk $(( iHeight / 2 )) $(( iHeight / 5 ))
tput sgr0

exit 0

bakunin

Last edited by bakunin; 12-24-2017 at 01:31 AM..
This User Gave Thanks to bakunin For This Post:
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To find the count of records from tables present inside a file.

hi gurus, I am having a file containing a list of tables.i want to find the count of records inside thes tables. for this i have to connect into database and i have to put the count for all the tables inside another file i used the following loop once all the tablenames are inside the file. ... (1 Reply)
Discussion started by: navojit dutta
1 Replies

2. What is on Your Mind?

Merry Christmas

Merry Christmas and all best wishes to all fox in this forum salute from Croatia (0 Replies)
Discussion started by: solaris_user
0 Replies

3. Shell Programming and Scripting

want to remove comma present inside double qoute

Hi friends... I have a dat file like below:- test_file.dat abc,ttt,"""123,89.98",yyu,opp vvv,"23,76.68",w564,"54,98.87",985 i need the remove the comma present inside the double qoute as output:- out_test_file.dat abc,ttt,"""12389.98",yyu,opp vvv,"2376.68",w564,"5498.87",985... (6 Replies)
Discussion started by: gani_85
6 Replies

4. Shell Programming and Scripting

Replace Special Character With Next Present Byte

Hi, First find the special character, from the special character take next two bytes convert the bytes to decimal and replace with next present byte of decimal value times. E.g. Input: 302619ú1A? Output: 302619(3 spaces for ú1A)?????????????????????????? Thanks, Dines (27 Replies)
Discussion started by: dineshnak
27 Replies

5. What is on Your Mind?

Merry XMAS, happy holidays etc. everybody...

Have a laugh... https://www.youtube.com/watch?v=HZWQcl1C-c8 Bazza... (4 Replies)
Discussion started by: wisecracker
4 Replies
WELCOME2L(1)						      Welcome2L User's Manual						      WELCOME2L(1)

NAME
Welcome2L - Linux ANSI boot logo. SYNOPSIS
Welcome2L [ -scr ] [ -getty ] [ -gettps] [ -msg ] [ -cpu ] [ -scrrand ] [ -xmas ] [ -xmasauto ] [ -lcol ] [ -nolf ] [ -private ] [-notime ] DESCRIPTION
Welcome2L is a little program that may run at login time to produce a BBS like ANSI login logo. It's very similar to Linux_Logo. But where Linux_Logo intends to be portable, Welcome2L intends to produce the best looking ANSI screens by making full usage of PC graphic characters. Therefore an architecture able to display those characters (i386, Alpha with TGA adapter, ... ) is required to use it. And, even if it will work on larger screens, it will only produce 80 column ANSI screens. OPTIONS
-getty Will display more accurate information when launched at boot time. -gettps Like -getty, but works with gettyps(8) program. -nolf Will not add an empty line to the ansi screen produced. -msg -msg"text of message" will show the message given as the distribution info. -cpu -cpu"name" will show the name given as the CPU name. -scrxx Will display screen number xx. -scrrand Will display a random screen. -xmas Will display an Xmas screen. -xmasauto Will automatically display an Xmas screen in December and January. -lcolxx Will change the prompt color to the color number xx. Type Welcome2L -help to see what number is attributed to a color. -private Display an "Unauthorized access is prohibited" line at the bottom of the ANSI screen. -notime When dispalying date information, do not display time. -noblink Turn blinking off. Useful with -xmas or -xmasauto on framebuffer devices, which do not support blinking. -help Will display usage information. EXAMPLE
/usr/bin/Welcome2L -getty -msg"Debian GNU/Linux" -lcol14 RESTRICTIONS
Welcome2L is not intended to run in a xterm. CAVEAT
Because "A 'welcome' page has been proven to be an invitation to come your system, thus making it legal to hack into your box." you may want to use the "-private" arg when running Welcome2L to display an "Unauthorized access is prohibited" line at the bottom of the ANSI screen. COPYRIGHT
Welcome2L Copyright (C)1998-1999 Little Igloo Org is freely distributable under the GNU Public License, a copy of which you should have received with this software (in a file called COPYING). AVAILABILITY
You can get the last Welcome2L version, sources, binaries distribution or RedHat Packages, at : http://www.LittleIgloo.org AUTHOR
Jean-Marc Jacquet <jm@littleigloo.org> 3rd Berkeley Distribution Welcome2L Version 3.04 WELCOME2L(1)
All times are GMT -4. The time now is 05:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy