Display Progress Status


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Display Progress Status
# 1  
Old 03-20-2005
Display Progress Status

Hi ,

I want to automate the Disk-Mirroring on Solaris.
After the sync is started, I can watch the progress with
sunos # metastat | grep done | cut -d ":" -f 2 | cut -d "%" -f 1
which results in a % value

How can I display some like

Synchronisation in progress : 1%----25%----50%----75%-----100%

Thanks for your suggestions

It is written on Solaris 9 with bourne shell
# 2  
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

# 3  
Old 03-22-2005
Here is a solution to your question using the script posted above. You should modify to print the % complete based upon the interval you want. You will of course want to submit this in the background (as noted above) and capture the PID so that you may appropriately kill this process. Also, the script below was written with the 'while true' condition. You could modify this to exit the script when the progress reaches 100 (or is complete).

Code:
function dots {
INTERVAL=1
FLAG='Y'
  while true
  do
    if [ $FLAG = 'Y' ]
      then
        echo "Synchronisation in progress :...\c"
        FLAG='N'
        PROGRESS='0'
    fi
    echo "..[${PROGRESS}%]\c"
    sleep $INTERVAL
    PROGRESS=$(metastat | grep done | cut -d ":" -f 2 | cut -d "%" -f 1)
  done
}

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
Login or Register to Ask a Question