Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Processing indicator

Status
Not open for further replies.

scriptfinder

Technical User
Apr 17, 2006
18
US
Hi! Folks!

Can someone help me with a code snippet to indicate processing, while my shell script is doing some work in the background?. The indicator's like continuous printing of forward slash, pipe, and backward slash or any thing else in the same character position.

Thank you very much in advance.

 
How about something like:
[tt]
while true; do
echo -en "\b/"
sleep 0.2
echo -en "\b-"
sleep 0.2
echo -en "\b\\"
sleep 0.2
echo -en "\b|"
sleep 0.2
done
[/tt]
This works in Debian Linux.
 
here's one link to look at.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Hi! TonyGroves!

I got the following error.

sleep: bad character in argument

I have SunOs. Any ideas?

Thanks.
 
It seems too slow.. but if there is no way I can break it into fractions of a second, I am okay with one.

thanks again...
 
check out if you have usleep command

usleep 200000 sleeps for 200000 microseconds or 0.2s


HTH,

p5wizard
 
A Couple that I've played with in the past

Code:
sign=("/" "-" "\\\\" "|"); pozi=0
 echo -n Working...
  while read strinf;do
    echo -en "${sign[$pozi]}\b; let pozi=(pozi+1)%4
  done < inputfile
echo ok

or in perl

Code:
$|=1;
print "Please wait...\n";
my @twirl=qw (-\|/);
for (my $counter=1| $counter <5; $counter ++)
 {
  print "\b\b$twirl[$counter %4]";
  sleep 1
 }
 print "Count Done.";

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
If you need a usleep for an OS which doesn't provide it, but do have a compiler handy, I wrote this C snippet to make the system call (works on Solaris):

Code:
#include <unistd.h>
#include <stdio.h>

int main (int argc, char *argv[]) {
        int sleeptime;

        if (argc < 2 || sscanf(argv[1],"%d",&sleeptime) != 1) {
                printf("usage: usleep <microseconds>\n");
                return 1;
        } else {
                return usleep(sleeptime);
        }
}

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top