Thursday, August 6, 2009

i wrote script to wish when u login!!!

First post.... :)
most of unix admins use putty to login, so when they login this thing wishes...
cool thing in this is it actully adjusts to the terminal size and prints at the center of the screen.. here it goes....

#!/bin/bash
#Author: Prudhvi raj
# Print greetings during login of user
########################################################
#funtion to print the greeting word by word
greet()
{
string=$1
tput clear
#echo -e " \c"
rows=`tput lines`
columns=`tput cols`
strng_len=`echo -n $string | wc -c`
indent=$(( ($columns / 2) - ($strng_len / 2) ))
verti_pos=$(( $rows / 2 ))
timevalue=`date +%S`
tput cup $verti_pos $indent
for(( i=1; i<=$strng_len; i++ ))
do
val=`echo $string | cut -c$i`
echo -e "$val\c"
usleep 100000
done
echo " "
}

#######################################################

n=`date +%H%M`

if [ $n -ge 0600 ] ;
then
if [ $n -le 1200 ] ; then
greet "Good morning `logname`"
else
if [ $n -le 1600 ] ; then
greet "Good afternoon `logname`"
else
if [ $n -le 2200 ] ; then
greet "Good evening `logname`"
else
greet "`logname` Go home!!!!!"
fi
fi
fi
else
greet "`logname` Go home!!!"
fi

#######################END###############################

Tuesday, August 4, 2009

First Post

{Where, what and how} do i start??
are the questions that are running in my mind now. Lets see how wil this thing go...