Solved

How do I show the progress of a korn-shell script in the form of continuous dots on the screen

Posted on 2010-09-14
4
716 Views
Last Modified: 2013-12-26
I have a shell script that calls 2 perl scripts.

A.ksh
---

A1.pl
A2.pl

==================

Now A2.pl calls 3 perl scripts within itself to generate the final result through the "system" command.

Is there any way that when I run

ksh A.ksh

when the program is executing, I can show the progress in the form of dots(....)
0
Comment
Question by:sunny82
  • 2
4 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33677973
I think this is only possible if all of your scripts would echo one or more dots to the terminal (without linefeed, of course) at some stage in their processing.
Your calling script cannot do that on their behalf.

wmp
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 33680119
This should give you the framework you need.

You may need to change

/bin/echo -n .

to

echo -e ".\c"

or

echo ".\c"

if the dots don't appear on the same line.
#!/bin/ksh

function dots {
  trap 'return' 3

  while true
  do
    /bin/echo -n .
    sleep 1
  done
}

echo "start"
dots &
pid=$!
A.pl
B.pl
kill  $pid
echo finish

Open in new window

0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33680250
Hehe, Tintin,
that's a real "Windows-style" progress meter! Writing a dot every second, regardless of the actual progress ...
Just joking!
wmp
0
 

Author Comment

by:sunny82
ID: 33685591
This is what I was looking for..Thx so much...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now