•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 363,786 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,532 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Here is a little spinner thing for the command line, used when your current bash script is waiting on a background/system process.
The weird character is ^H or a backspace.
The weird character is ^H or a backspace.
Last edited : May 9th, 2007.
## This is similar to what FreeBSD does when it is booting ### some command & ### do_progress_spin_l $! # A small "asterik" like thing will spin until the process is complete #+ (when ps ax | grep PID no longer finds anything) do_progress_spin_l() { ## The characters to use # These will be overlapped via ^H ICON[0]="/" ICON[1]="-" ICON[2]="\\" ICON[3]="|" ## The process we wish to monitor PROCESS=$1 ## Initialize count value # print out first icon icon_num=0 echo -n ${ICON[$icon_num]} ## While the process exists in ps ax, do this loop while ( ps ax | grep $PROCESS | grep -v "grep" 1>/dev/null ) do ## If our count is bigger than 3 (our highest number icon) # reset it to 0 if [ "$icon_num" -gt "3" ]; then icon_num=0 fi ## ^Hnew_icon echo -n ${ICON[$icon_num]} icon_num=`expr $icon_num + 1` sleep 0.5 # sleep 1 done ## Little clean-up. Print done and a new line echo -n "... Done" echo "" }
Comments (Newest First)
Stylish | Junior Poster in Training | May 9th, 2007
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)