Sponsored Content
Full Discussion: Display Progress Status
Top Forums Shell Programming and Scripting Display Progress Status Post 67087 by google on Monday 21st of March 2005 11:32:05 AM
Old 03-21-2005
Here are 3 different solutions to provide a user with feedback. All you have to do is add in your statement to grab the % complete and you are there. I wish I could take credit for this code but they were not my ideas. Happy to pass them along (I have used them in the past).

-- Not too fancy, just produces some dots on the screen
Code:
function dots
{
     while true
     do
          echo ".\c"
     done
}

-- Different feedback to the user - this time a twirling bar
Code:
function twirl
{
TCOUNT="0"      # For each TCOUNT the line twirls one increment

while :         # Loop forever...until you break out of the loop
do
       TCOUNT=$(expr ${TCOUNT} + 1) # Increment the TCOUNT

       case ${TCOUNT} in
           "1")    echo '-'"\b\c"
                   sleep 1
                   ;;
           "2")    echo '\\'"\b\c"
                   sleep 1
                   ;;
           "3")    echo "|\b\c"
                   sleep 1
                   ;;
           "4")    echo "/\b\c"
                   sleep 1
                   ;;
           *)      TCOUNT="0" ;;  # Reset the TCOUNT to "0", zero.
       esac
done
# End of twirl finction
}

-- A better solution, this function executes in the background and provides the user with feedback in the form of a rotating bar. A much better solution. Add in your % complete functionality and you've got it.
Code:
function rotate
{
# PURPOSE: This function is used to give the end user some feedback that 
# 	"something" is running.  It gives a line twirling in a circle.
#	This function is started as a background process. Assign its' PID
#    to a variable using:
#
#             rotate &      # To start 
#             ROTATE_PID=$! # Get the PID of the last background job
#
#       At the end of execution just break out by killing the $ROTATE_PID
#       process. We also need to do a quick "cleanup" of the left over 
#       line of rotate output. 
#
#           FROM THE SCRIPT:
#             kill -9 $ROTATE_PID
#             echo "\b\b   "

INTERVAL=1     # Sleep time between "twirls"
TCOUNT="0"	    # For each TCOUNT the line twirls one increment

while :        # Loop forever...until this function is killed
do
	TCOUNT=`expr $TCOUNT + 1`   # Increment the TCOUNT

	case $TCOUNT in
		"1")	echo '-'"\b\c"
			sleep $INTERVAL
			;;
		"2")	echo '\\'"\b\c"
			sleep $INTERVAL
			;;
		"3")	echo "|\b\c"
			sleep $INTERVAL
			;;
		"4")	echo "/\b\c"
			sleep $INTERVAL
			;;
		*)	TCOUNT="0" ;;  # Reset the TCOUNT to "0", zero.
	esac
done
} # End of Function - rotate

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Couldn't open status file /var/samba/STATUS.LCK

I believe i have most of samba configured right but i get this error each time time try to run it. I was given suggestion that i touch the file, i did, but i still cannot rid myself of this error. Any suggestions (2 Replies)
Discussion started by: macdonto
2 Replies

2. AIX

Process status display

On AIX 5.2, I use "ps -ef " command to display the process status, the field of command looks like: , the detailed contents are: # ps -ef |grep rtesfmrt Display: osa 32455 1 0 18:20 - 1:57 The origianl format shoud be: osa 32455 1 0 18:20 - 1:57 ... (2 Replies)
Discussion started by: Frank2004
2 Replies

3. Shell Programming and Scripting

check the status and send an email with status

Hi, We have a text file which has the following data. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002 ST~997~0001 AK1~SH~247 AK2~856~2470001 AK5~A AK2~856~2470002 AK5~A... (3 Replies)
Discussion started by: isingh786
3 Replies

4. Red Hat

Installing RedHat 8.0 onto Dell PowerEdge SC1425 - hdc: status error: status = 0x58

I have successfully installed RedHat 8.0 onto a Dell PowerEdge SC1425 today. This server has two SATA hard drives, and an IDE DVD-ROM drive. Using the following kernel parameters, i successfully installed across both hard drives from CD: ide0=0x1f0,0x3f6,14 vga=791 resolution=1024x768 expert... (5 Replies)
Discussion started by: fishsponge
5 Replies

5. Shell Programming and Scripting

pass curls progress/status data to a file

hello hackers again. please help me out once again. i have a script which executes CURL to fetch a file from the web and instantly outputs the files content to STDOUT. now my question - can i somehow write the progress-status to a file? so that curl acts silently (-s) and only puts... (0 Replies)
Discussion started by: scarfake
0 Replies

6. Shell Programming and Scripting

Show status of progress?

So, What is the best method, if even possible, to display a percentage or a status or progress of a certain command? For example I am forcing a block copy of a an OS image from one machine to another via a shell script and would like for it to display a progress or status so I know if it is... (3 Replies)
Discussion started by: tlarkin
3 Replies

7. Shell Programming and Scripting

Display status of instances in apache - Where to start

Hello, I know this is not a simple question so I just need to know where to start for below project: I am running under Ubuntu 18.04 What I'd like to see in apache page is to display status of particular process pids. ps aux | grep keywords.txt keywords.txt word1 word2 word3 word4... (9 Replies)
Discussion started by: baris35
9 Replies

8. Programming

How to track table status delete/update/insert status in DB2 V10 z/os?

Dear Team I am using DB2 v10 z/os database . Need expert guidance to figure out best way to track table activities ( Ex Delete, Insert,Update ) Scenario We have a table which is critical and many developer/testing team access on daily basis . We had instance where some deleted... (1 Reply)
Discussion started by: Perlbaby
1 Replies

9. UNIX for Beginners Questions & Answers

How to see the status of all the ftp put & get files logs and curent ftp transfer status ?

How to see the status of all the ftp put & get files logs and curent ftp transfer status if any active ftp running in the background ? (2 Replies)
Discussion started by: i4ismail
2 Replies
Mail::SpamAssassin::Util::Progress(3)			User Contributed Perl Documentation		     Mail::SpamAssassin::Util::Progress(3)

NAME
Mail::SpamAssassin::Util::Progress - Progress bar support for SpamAssassin SYNOPSIS
my $progress = Mail::SpamAssassin::Util::Progress->new({total => 100}); $msgcount = 0; foreach my $message (@messages) { # do something here $msgcount++; $progress->update($msgcount); } $progress->final(); DESCRIPTION
This module implements a progress bar for use in SpamAssassin scripts and modules. It allows you to create the progress bar, update it and print out the final results of a particular run. new public class (Mail::SpamAssassin::Util::Progress) new (\% $args) Description: Creates a new Mail::SpamAssassin::Util::Progress object, valid values for the $args hashref are: total (required) The total number of messages expected to be processed. This item is required. fh [optional] An optional filehandle may be passed in, otherwise STDERR will be used by default. term [optional] The module will attempt to determine if a valid terminal exists on the STDIN filehandle. This item allows you to override that value. init_bar public instance () init_bar() Description: This method creates the initial progress bar and is called automatically from new. In addition you can call init_bar on an existing object to reset the bar to it's original state. update public instance () update ([Integer $num_done]) Description: This method is what gets called to update the progress bar. You may optionally pass in an integer value that indicates how many messages have been processed. If you do not pass anything in then the num_done value will be incremented by one. final public instance () final ([Integer $num_done]) Description: This method should be called once all processing has finished. It will print out the final msgs per sec calculation and the total time taken. You can optionally pass in a num_done value, otherwise it will use the value calculated from the last call to update. perl v5.16.3 2011-06-06 Mail::SpamAssassin::Util::Progress(3)
All times are GMT -4. The time now is 02:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy