Shell keepalive throbber thingy





0
Date Submitted Thu. Sep. 25th, 2008 4:52 AM
Revision 1 of 1
Beginner KennethCC
Tags bash
Comments 1 comments
Small amount of bash shell code to produce terminal output. I use this to keep alive ssh connections where the server will automatically disconnect a session where input is not received for a small amount of time.
Needs: A terminal that understands ansi.sys escape codes. Most modern interactive terminals. You might have limited success on serial terminals.
CAVEAT: Admittedly

watch date

would do the same job - but is less fun.
In use I have this in a function in my .bashrc

function keepalive () {

}

#!/bin/bash
##############################################################
# Keep alive console thingy for SSH connections that like to #
# kick out after inactivity regardless of settings           #
##############################################################
    # Different throbbers - last defined is used
    # or remove all except the one you want
    T='./^\'                       # Hop-a-long
    T='
.o'                         # throbber
    T='
0123456789-*-9876543210-*-' # counter
    T='
!|!'                        # jumping jacks
    T='
`\,\'                       # bouncing stick
    T='
/%/'                        # pulse
    T='
_-==-'                      # flying
    T='
ooooooo-'                   # wink
    T='
._-`-_'                     # bob-a-long
    T='
._o@o'                      # inflate-deflate
    T='
\|/-'                       # propeller

    sleep='
sleep 1'      # Some "sleep"s only handle integers
    sleep='
usleep 50000' # Some systems can use  "usleep"
    sleep='
sleep 0.2'    # some "sleep"s can handle fp params
 
    for((i=1;i<=${#T};i++)); do
        echo -e '
\033[K\033[1;1H'${T:((i-1)):1}' '"\t"$(date)
        [ $i -eq ${#T} ] && i=0
        $sleep
    done
 

Kenneth CC

Comments

Comments Syntax colouring error
Thu. Sep. 25th, 2008 4:58 AM    Beginner KennethCC

Voting

Votes Up


Votes Down