Sponsored Content
Top Forums Shell Programming and Scripting show dots when script is "thinking" Post 302419590 by curleb on Friday 7th of May 2010 02:40:51 PM
Old 05-07-2010
I'm thinking, I'm thinking...I'm...thinking:

Code:
#!/bin/ksh
# busy - show progress indicators
# Heiner Steven (heiner.steven@odn.de)
#
#  usage:
#     busy& busipid=$!
#     # do some actions
#     kill $busypid
#  set -x 

#  Give some eye candy... 
set -A Indicators -- "\n  |o.............................|  " \
                     "\n  |0o............................|  " \
                     "\n  |)0o...........................|  " \
                     "\n  |()0o..........................|  " \
                     "\n  |0()0o.........................|  " \
                     "\n  |o0()0o........................|  " \
                     "\n  |.o0()0o.......................|  " \
                     "\n  |..o0()0o......................|  " \
                     "\n  |...o0()0o.....................|  " \
                     "\n  |....o0()0o....................|  " \
                     "\n  |.....o0()0o...................|  " \
                     "\n  |......o0()0o..................|  " \
                     "\n  |.......o0()0o.................|  " \
                     "\n  |........o0()0o................|  " \
                     "\n  |.........o0()0o...............|  " \
                     "\n  |..........o0()0o..............|  " \
                     "\n  |...........o0()0o.............|  " \
                     "\n  |............o0()0o............|  " \
                     "\n  |.............o0()0o...........|  " \
                     "\n  |..............o0()0o..........|  " \
                     "\n  |...............o0()0o.........|  " \
                     "\n  |................o0()0o........|  " \
                     "\n  |.................o0()0o.......|  " \
                     "\n  |..................o0()0o......|  " \
                     "\n  |...................o0()0o.....|  " \
                     "\n  |....................o0()0o....|  " \
                     "\n  |.....................o0()0o...|  " \
                     "\n  |......................o0()0o..|  " \
                     "\n  |.......................o0()0o.|  " \
                     "\n  |........................o0()0o|  " \
                     "\n  |.........................o0()0|  " \
                     "\n  |..........................o0()|  " \
                     "\n  |...........................o0(|  " \
                     "\n  |............................o0|  " \
                     "\n  |.............................o|  " \
                     "\n  |............................o0|  " \
                     "\n  |...........................o0(|  " \
                     "\n  |..........................o0()|  " \
                     "\n  |.........................o0()0|  " \
                     "\n  |........................o0()0o|  " \
                     "\n  |.......................o0()0o.|  " \
                     "\n  |......................o0()0o..|  " \
                     "\n  |.....................o0()0o...|  " \
                     "\n  |....................o0()0o....|  " \
                     "\n  |...................o0()0o.....|  " \
                     "\n  |..................o0()0o......|  " \
                     "\n  |.................o0()0o.......|  " \
                     "\n  |................o0()0o........|  " \
                     "\n  |...............o0()0o.........|  " \
                     "\n  |..............o0()0o..........|  " \
                     "\n  |.............o0()0o...........|  " \
                     "\n  |............o0()0o............|  " \
                     "\n  |...........o0()0o.............|  " \
                     "\n  |..........o0()0o..............|  " \
                     "\n  |.........o0()0o...............|  " \
                     "\n  |........o0()0o................|  " \
                     "\n  |.......o0()0o.................|  " \
                     "\n  |......o0()0o..................|  " \
                     "\n  |.....o0()0o...................|  " \
                     "\n  |....o0()0o....................|  " \
                     "\n  |...o0()0o.....................|  " \
                     "\n  |..o0()0o......................|  " \
                     "\n  |.o0()0o.......................|  " \
                     "\n  |o0()0o........................|  " \
                     "\n  |0()0o.........................|  " \
                     "\n  |()0o..........................|  " \
                     "\n  |)0o...........................|  " \
                     "\n  |0o............................|  " \


#  Make an array of the aforementioned eye candy... 
integer n=${#Indicators[@]}
integer i=0

#  While condition exists, present status to screen... 
while [[ -f bpc.txt ]] 2>/dev/null #true
do
   clear 
#   print -n -- "Running ... \n\t${Indicators[i]}\n"
   print "Running ... \n\t${Indicators[i]}\r"
   ((i=(i+1)%n))
#  sleep 1
#  clear
done

Note that you'd want to modify the condition that drives the while... loop.

Last edited by curleb; 05-07-2010 at 04:24 PM.. Reason: reduce flicker per print args...
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

3. Shell Programming and Scripting

perl - Removing dots(".") from the data

Hi Friends, I have a file1 as below file1.txt 100000.||1925-01-10|00:00|1862SHERMA NAVE#1SE.||EVTON|IL|60201||22509.|BDSS|62007|2639.|26670 100001.||1935-01-10|00:00|1862NEW . YRK NO.||EVTON|IL|60201||22509.|BDSS|62007|2639.|26670. 100002.||1965-01-10|00:00|1862 IND . INC,CL... (6 Replies)
Discussion started by: i150371485
6 Replies

4. Shell Programming and Scripting

Awk-sed - wc : how to count DOTS "."'s in a file.

Hi Experts , file: EST 2013::.................................................................................................................................................................................................................................................cmihx021:/home/data1/ ... (11 Replies)
Discussion started by: rveri
11 Replies

5. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

6. Red Hat

"/usr/sbin/hpacucli ctrl all show" command does not work

Dear Concern, We have observed that following command stuck/does not work in some RedHat nodes. Please advise us to troubleshoot the issue. /usr/sbin/hpacucli ctrl all show Note: HP Array Configuration Utility CLI for Linux 64-bit With Best Regards, Md. Abdullah-Al Kauser (3 Replies)
Discussion started by: makauser
3 Replies

7. Shell Programming and Scripting

Can someone please show me a very simple "expect" script to change password in Solaris please?

Ladies & Gents, Can one of you gurus please show me a very simple "expect" script to change the password in Solaris in a script, please? Nothing fancy, no error checking, no nothing. Just to change the password of a new user, it's all. Many thanks in advance. U guys have honestly earned my... (1 Reply)
Discussion started by: Hiroshi
1 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
All times are GMT -4. The time now is 04:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy