Register
It is currently Fri Oct 31, 2014 1:17 pm

Spinners and other fun stuff.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 10 posts ] 
Author Message
 PostPosted: Sat Apr 08, 2006 1:41 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
Here is a use I though of for it....
Code:
#!/bin/bash
search ()
{
        delay1='sleep .08'
   wipescreen='echo -ne \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b'
echo -ne "|                                                          ";$delay1;$wipescreen
echo -ne "/                                                            ";$delay1;$wipescreen
echo -ne "-                                                          ";$delay1;$wipescreen
echo -ne "\                                                          ";$delay1;$wipescreen
echo -ne "|                                                        ";$delay1;$wipescreen
echo -ne "/                                                       ";$delay1;$wipescreen
echo -ne "-                                                       ";$delay1;$wipescreen
echo -ne "\                                                    ";$delay1;$wipescreen
echo -ne "|                                                   ";$delay1;$wipescreen
echo -ne "";$delay1;$wipescreen
}
echo "Please wait while the computer searches for the file... "
search
locate $1

It the little spinny thing you see on most linux installers...
Ok, I have though of a use for this little function but can anyone tell me if you can use if to see if a certain script or file is running...

[mod] Split from other topic as it had started to stray from the original post[/mod]


Top
 Profile WWW  
 PostPosted: Sat Apr 08, 2006 10:30 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
Code:
#!/bin/bash
spin ()
{
BLUE='\e[0;34m'
RED='\e[0;31m'
WHITE='\e[1;37m'
NC='\e[0m'

echo -ne "${RED}-"
echo -ne "${WHITE}\b|"   
echo -ne "${BLUE}\bx"
sleep .02
echo -ne "${RED}\b+${NC}"
}

for i in `seq 1 15` ; do spin; done
exit


Try that for a spinner instead crudball.... ;) You can change the duration of spin, and length of spin pretty easily this way. Calling the spinner is a one line thing as well.


Last edited by crouse on Sat Apr 08, 2006 11:50 am, edited 1 time in total.

Top
 Profile WWW  
 PostPosted: Sat Apr 08, 2006 10:54 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
that doesnt spin!
terminal wrote:
[root@localhost rob]# ./spin
+++++++++++++++[root@localhost rob]#


Top
 Profile WWW  
 PostPosted: Sat Apr 08, 2006 11:53 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 669
Location: Des Moines, Iowa
Code:
#!/bin/bash
spin ()
{
BLUE='\e[0;34m'
RED='\e[0;31m'
WHITE='\e[1;37m'
NC='\e[0m'

echo -ne "${RED}-"
echo -ne "${WHITE}\b|"   
echo -ne "${BLUE}\bx"
sleep .3
echo -ne "${RED}\b+${NC}"
}

for i in `seq 1 15` ; do spin; done


does more of a progress bar thing than just sitting and spinning.....

and another version of this.....

Code:
#!/bin/bash
function spin {
    echo -n '-'
    echo -ne '\b|'   
    sleep .1
    echo -ne '\bx'
    sleep .1
    echo -ne '\b+'
}
for i in `seq 1 15` ; do spin; done   
echo ""
exit


Top
 Profile WWW  
 PostPosted: Sat Apr 08, 2006 12:05 pm   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
i like this one... you have to cntrl+C it... but it's kinda cool... and was used in a couple scripts that take awhile...
Code:
#!/bin/bash

shopt -s -o nounset
trap 'echo -e "\b\b\b\b\b\b\b\b\b|=======|> done!"' EXIT
        echo -n "|/     |"
        while true
        do
        # moving right
        echo -ne "\b\b\b\b\b\b\b-     |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\b\\     |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\b|     |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\b /    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b-    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\\    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b|    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b /   |"
        sleep .03
        echo -ne "\b\b\b\b\b-   |"
        sleep .03
        echo -ne "\b\b\b\b\b\\   |"
        sleep .03
        echo -ne "\b\b\b\b\b|   |"
        sleep .03
        echo -ne "\b\b\b\b\b /  |"
        sleep .03
        echo -ne "\b\b\b\b-  |"
        sleep .03
        echo -ne "\b\b\b\b\\  |"
        sleep .03
        echo -ne "\b\b\b\b|  |"
        sleep .03
        echo -ne "\b\b\b\b / |"
        sleep .03
        echo -ne "\b\b\b- |"
        sleep .03
        echo -ne "\b\b\b\\ |"
        sleep .03
        echo -ne "\b\b\b| |"
        sleep .03
        echo -ne "\b\b\b /|"
        sleep .03
        echo -ne "\b\b-|"
        sleep .03
        echo -ne "\b\b\\|"
        sleep .03
        echo -ne "\b\b||"
        sleep .03
        echo -ne "\b\b/|"
        sleep .03

        # moving left
        echo -ne "\b\b||"
        sleep .03
        echo -ne "\b\b\\|"
        sleep .03
        echo -ne "\b\b-|"
        sleep .03
        echo -ne "\b\b\b/ |"
        sleep .03
        echo -ne "\b\b\b| |"
        sleep .03
        echo -ne "\b\b\b\\ |"
        sleep .03
        echo -ne "\b\b\b- |"
        sleep .03
        echo -ne "\b\b\b\b/  |"
        sleep .03
        echo -ne "\b\b\b\b|  |"
        sleep .03
        echo -ne "\b\b\b\b\\  |"
        sleep .03
        echo -ne "\b\b\b\b-  |"
        sleep .03
        echo -ne "\b\b\b\b\b/   |"
        sleep .03
        echo -ne "\b\b\b\b\b|   |"
        sleep .03
        echo -ne "\b\b\b\b\b\\   |"
        sleep .03
        echo -ne "\b\b\b\b\b-   |"
        sleep .03
        echo -ne "\b\b\b\b\b\b/    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b|    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\\    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b-    |"
        sleep .03
        echo -ne "\b\b\b\b\b\b\b/     |"
        sleep .03
        done


Top
 Profile  
 PostPosted: Sun Apr 09, 2006 6:02 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
Heres a nice one:
Code:
#!/bin/bash
search ()
{
        delay1='sleep .08'
   wipescreen='echo -ne \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b'
echo -ne "c       ";$delay1;$wipescreen
echo -ne "cr      ";$delay1;$wipescreen
echo -ne "cru     ";$delay1;$wipescreen
echo -ne "crud    ";$delay1;$wipescreen
echo -ne "crudb   ";$delay1;$wipescreen
echo -ne "crudba  ";$delay1;$wipescreen
echo -ne "crudbal ";$delay1;$wipescreen
echo -ne "crudball";$delay1;$wipescreen
echo -ne " rudball";$delay1;$wipescreen
echo -ne "  udball";$delay1;$wipescreen
echo -ne "   dball";$delay1;$wipescreen
echo -ne "    ball";$delay1;$wipescreen
echo -ne "     all";$delay1;$wipescreen
echo -ne "      ll";$delay1;$wipescreen
echo -ne "       l";$delay1;$wipescreen
echo -ne "        ";$delay1;$wipescreen
search
}
search


Top
 Profile WWW  
 PostPosted: Mon Jun 12, 2006 10:16 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
Here is a clock using the same basic format:
Code:

#!/bin/bash
clock ()
{
        delay1='sleep 1'
   wipescreen='echo -ne
\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\$
echo -ne "`date +"%H:%M:%S"`";$delay1 ;$wipescreen
clock
}
clock

The date command can be modified to suite - man date or date --help.


Top
 Profile WWW  
 PostPosted: Mon Nov 20, 2006 2:54 pm   

Joined: Mon Nov 20, 2006 2:03 am
Posts: 3
can i ask, if i want to use the spinner, until, lets say nmap finishes run, how will you manage to stop it after nmap completes scan ?


Top
 Profile  
 PostPosted: Sun Nov 18, 2007 9:14 am   

Joined: Sun Nov 18, 2007 8:28 am
Posts: 6
This would be interesting to show in the terminal possibly in front of the prompt. & does it half way but the output interferes with the information at the prompt.


Top
 Profile WWW  
 PostPosted: Thu Aug 28, 2008 5:16 am   

Joined: Thu Aug 28, 2008 4:15 am
Posts: 3
Location: India
This is in reply to

if i want to use the spinner, until, lets say nmap finishes run, how will you manage to stop it after nmap completes scan ?

well you could do that by puttin it in while loop, like

while ( ps -aef | grep "nmap" 1>/dev/null )


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP