Process indicator with hash marks


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Process indicator with hash marks
# 1  
Old 08-06-2009
Process indicator with hash marks

Hi Experts,

I have written a php script that calls several smaller bash shell scripts throughout it's loop process. Users run this script to achieve a task that this script has automated. However this script depending upon the amount of input variables could take some time to run. It may be a short amount of time. Or long amount.

Is it possible to add some kind of processing indicator to my script to show the amount or percentage that has completed. So the end user can judge completion time?

Any help would be appreciated.
# 2  
Old 08-06-2009
Hi.

IMO: Using simple PHP and shell, it's not possible. This is because the output from your shell script is returned, after the script is finished, to the web server and processed before it's sent to the browser. (the output of your shell script is returned to PHP, which then prints it, and all this gets sent to the client browser)

Sure, it's easy to create some kind of indicator in a shell script, but your browser would never see it.

That's not to say it's not possible to do what you want (it's certainly possible), but perhaps this is not the best forum to answer your question. It's more of a web thing than a shell thing.
# 3  
Old 08-06-2009
One thing I've seen implemented in the past is some sort of message and/or icon that indicates there is something going on in the background. Not necessarily a progress meter, but just something that says "Hey, I'm busy, gimme a sec". You could have a pop-up box or a div that shows a spinning hour glass and the text "Working...".

This would indicate to your users that something is happening in the background and they should wait. It doesn't tell them how far along the process is but it should be enough to just tell them to be patient. If you don't do anything but wait people will assume they've lost connection or there's a problem with the server (which is probably why you posted the message in the first place).
# 4  
Old 08-06-2009
Thanks for the replys.

The users issue this script from a BASH prompt. So even if there can see some sort of hash marks that go by the screen, similar to when installing a rpm using the install verbose hash flags would be great.

I will keep searching around for this. Thanks again.

Jaysunn
# 5  
Old 08-06-2009
What you are trying to do is to create a progress bar. This is a crude (ksh) version of one that works only on a console window. Not gnome or whatever. search for other examples as 'progress bar in shell script'
This one has ten steps, your working code will call pbar only ten times.
Code:
#!/bin/ksh 

set -A disp '|x' '|xx' '|xxx' '|xxxx' '|xxxxx' '|xxxxxx' '|xxxxxxx' '|xxxxxxxx' '|xxxxxxxxx'

pbar()
{
   if [ $1 -gt 
   echo '\033[25;25H'${disp[$1]}'\033[25;37H|\n'
}

i=0  
clear
while :
do
   pbar $i
   i=$(( $i + 1 ))
   sleep 2
done

# 6  
Old 08-06-2009
This is exactly what I am looking for to start modifying. Thanks Alot for all your replys.

Jaysunn
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to print hash of hash in table format

Hi, I have a hash of hash where it has name, activities and count i have data like this - $result->{$name}->{$activities} = $value; content of that are - name - robert tom cat peter activities - running, eating, sleeping , drinking, work i need to print output as below ... (3 Replies)
Discussion started by: asak
3 Replies

2. Shell Programming and Scripting

Dynamically parse BibTeX and create hash of hash

Hello gurus, Iam trying to parse following BibTex file (bibliography.bib): @book{Lee2000a, abstract = {Abstract goes here}, author = {Lee, Wenke and Stolfo, Salvatore J}, title = {{Data mining approaches for intrusion detection}}, year = {2000} } @article{Forrest1996, abstract =... (0 Replies)
Discussion started by: wakatana
0 Replies

3. Shell Programming and Scripting

Compare values of hashes of hash for n number of hash in perl without sorting.

Hi, I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all . my %result ( $abc => { 'data_count' => '10', 'ID' => 'ABC122', } $def => { 'data_count' => '20', 'ID' => 'defASe', ... (1 Reply)
Discussion started by: asak
1 Replies

4. Shell Programming and Scripting

Protecting variable indicator ($) from expansion

Hello, I use a lot this command to edit a bunch of files at once find . -name filename" | xargs -ifoo sh -c 'echo foo ; sed "s/pattern1/pattern2/" foo > ./tmp ; mv -f ./tmp foo' I'm trying to put a function on my .bashrc file. function loopSed() { local filename=$1 local... (2 Replies)
Discussion started by: phollox
2 Replies

5. UNIX for Advanced & Expert Users

Command to output ones (like zero-fill), with progress indicator

Well, I was originally going to post this snippet in the original thread titled "how to output ones endlessly like /dev/zero", but that topic was closed without an efficient answer. It was difficult to find (build) a satisfactory answer to this one, so I thought I'd share it here and as a "fill... (1 Reply)
Discussion started by: Gliktch
1 Replies

6. Shell Programming and Scripting

perl hash - using a range as a hash key.

Hi, In Perl, is it possible to use a range of numbers with '..' as a key in a hash? Something in like: %hash = ( '768..1536' => '1G', '1537..2560' => '2G' ); That is, the range operation is evaluated, and all members of the range are... (3 Replies)
Discussion started by: dsw
3 Replies

7. Shell Programming and Scripting

Perl Hash:Can not keep hash data in the same order that it was inserted

Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below. #!/usr/bin/perl use warnings; use Tie::IxHash; use strict; tie (my %programs, "Tie::IxHash"); while (my $line = <DATA>) { chomp $line; my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies

8. Shell Programming and Scripting

Hash marks when running tar or zip from Cshell

Does anyone know how to get hash marks (or some other visual indicator) to print to the screen during tar or zip commands run from within a Cshell on Sun or Linux? Currently the user receives no indication that a command is running and cannot be sure that a problem has not occurred. I can find... (3 Replies)
Discussion started by: phudgens
3 Replies

9. Shell Programming and Scripting

Progress indicator script

Can anybody suggest you a good script to show progress of a process. I figured it out some thing like this. But cursor goes to the end of the line and after every loop it goes to the next line. while true ; do for i in \| \/ \- \\ \| \/ \- \\ do echo "\b\b$i \c" sleep 1 done done (8 Replies)
Discussion started by: ./hari.sh
8 Replies

10. Shell Programming and Scripting

Print Entire hash list (hash of hashes)

I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes). Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash. Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies
Login or Register to Ask a Question