Programming :: Progress Bar Instead Of Percentage Complete For Loop
Nov 25, 2010
I've got a loop which is able to echo out how complete a process is after each loop (e.g says 25% if the loop has 4 elements and has run once through). Is there any way I can print characters, perhaps a progress bar? I was thinking of using the percentage as a count or something and using.
Code:
I got told off for including code from work here.
After searching I cant find script that can deal with directories. All the found scripts work file to file and not directory to directory. Someone know script that can deal with all this situation?
I would really like to capture the output of scp and my file's progress. Scp updates the transfer rate every 1 second, and I will like to save the transfer rate at every update. So for example, if the file transfer takes 30 seconds, I would like 30 reports of the transfer rate.
The output looks like: Code: file.dat 1% 3664KB 938.5KB/s 05:48
Whenever I try a simple redirect like: Code: scp file.dat 192.168.1.100:~/ &> output ... it does not save the rate at every update, it only shows the final rate.
If I try using typescript by starting "script" ... it's the same deal.
I'm writing a script to automate rsync backups which so far is working great. I prefer to send output to a text file instead of watching it fly by but the blank output is slightly boring? I would love to use a progress bar. Not for each file but for overall progress. Something like
syncing /home directory 50% [++++++++]
I already know it's way over my head and maybe bash isn't even the right tool for the job.
I am busy writing this script to get a pixel count of a large batch of images in a directory for a research project. To do this I'm using a loop to get all the images in the directory. To make the whole procedure more user friendly for some colleagues I decided to use zenity, something I haven't yet really worked with. As not to make sure that the users don't have to watch to this blank screen during the actual processing of the images I'm trying to get the zenity progress bar working. So far the progress bar comes up but instead of changing over time it stays "empty" till all the images are processed and then becomes 100% when all images are done. What servers my needs for now, but since I am trying to learn more about zenity I was wondering how I could change the script to get the progress bar properly working? Below is the piece of script I am talking about.
Code: cd $input #goto path of image directory (for a in *jpg *JPG *jpeg *JPEG; do if [ -f "$a" ]; then #was it a image file b="$a" #set b to $a convert -resize 1000x1000! ${b} -depth 1 -format %c histogram:info:$b.txt #get pixelcount and write to .txt file fi done) | zenity --progress
I am attempting to "export" the progress bar from wget display using sed. Basically, we have an app that starts wget to download a large file and we want to show a progress bar. Our application has a dbus interface to receive the download progress.
So we were think of a command like: wget [] | sed [] | dbus-send[] The problem at the moment is, how do you get the matched string out of sed and into dbus-send? I can get the progress string by: sed -u 's/[0-9]*%/&/'
This populated '&' with the correct percentage, but I cannot seem to get this out of sed.
I need to rename the resulted searched files from a loopI have the following code:
find . -name DOC* | while read i do find $i -type f -name '*.txt' done
basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell
i have written a bash script to convert flv files (e.g. videos) to xvid to be played on my dvd player. the conversion is not really the issue, as it works. what i am dealing with now are 2 problems i have not found a good workarouond: 1. surpressing the shell output of mencoder completely ( i do not want to see all the mencoder messages). this i have only solved to a certain extend. 2. i want to create a progress bar. this one i have not yet cracked.
#start the script main_menu 1. mencoder output: using /dev/null works more or less. for example: if mencoder detects a double frame while converting, a message is still printed on the bash screen 2. progressbar: i have no clue yet on how to do this. any link or tip is welcome. my goal is something like this: [56%] [time in progress] [timeleft]
I just cant seem to understand loops. i havent put the loop in yet but what i would like is the user only to have 3 tries at guessing number then exit if wrong or it says "correct if right" tbh i dont even know if the above code is correct. i have tried several ways and position of the loops but each time is comes out wrong
I am trying to do some shell programs. I tried some sites regarding the while loop, they give the structure as: Code: while [ n1 -lt 500 ] do echo $((n1+100)) done
But the below code also worked for me: Code: while ((n1 > 500)) do echo $((n1+100)) done By using (( )) I could use while, for. But the documentations didnt follow this way. I mainly use this for datastructure programming.
In the code segment below is a for loop I am having some considerable difficulty with. It just keeps iterating endlessly and totally ignores the 70 times limit specified. I can't ever remember having this problem before and am absolutely Clueless.
Code: for ( x = 0; x < 70; x++ ) { fputs ("CSN00", target); fprintf (target, "%d", userid);
I've got a 'nested' for loop which has a grep in it, if the grep fails there's no output - however the error code is still $0 and the second for loop is still entered, there's also a grep in the second for loop.I guess ultimately what i need to know is whether there's a way of making grep generate an error code. when no results are found?
I want to loop through the records in the below file (homedir.temp) /home/user1 /home/user2 /home/user3
I want to do the following activities with each record1. du -s - to get the total usage for that directory (my variable name is SIZE)2. divide SIZE by du -c for /home to get the percentage of usage. (my variable name is PER)3. write the directory, SIZE, PER to a filePROBLEMI am using the below for loop: for record in homedir.tempthe mentioned activitiesdonehe above is not looping through the records. It does the first record perfectly and exits the loop.
When I deal with an array in a function I con not access to the content of array in a for loop, but out of a for loop I can access to them! for example
[code]...
In a function when I send as parameter, in a for loop it prints the content of array and out of a for loop it prints the address of arr[i]
I'm writing a mass snmp toner check which polls any toners available to be snmp polled, however when using a loop statement I get the results on different lines; which sounds good, however the tool I use to check with (nagios) ignores the new lines.
Is there any way I can get the output on one line? Also, I need to raise a fault if any of the toners are below a specific level (with nagios you raise faults with the exit code) - any way I can do this without exiting the loop. Code below with bits and bobs commented out.
I have a 50 file name NSSAVE0001.vtk to NSSAVE0050.vtk.Do I have to manually type individually command to open each file or can I have a loop to open file?
I need to pass a large number of arguments to a function which takes variable number of arguments, such as gtk_list_store_new. But it doesn't look nice if i write something like gtk_list_store_new(NUM,TYPE_A,TYPE_B,TYPE_C,...,TYPE_OMEGA); because of large number of arguments. And, it will be a trouble to change number of columns because of need to manually change arguments to large number of such functions. So, how can i pass all the arguments to a function using a loop? Something like
I used imagemagick to convert the files to gif with the following command
Code:
for i in {100..131}; do convert CIMG0$i.jpg CIMG0$i.gif; done # works
This worked like expected, but when afterwards I wanted to scale the images
Code:
for i in {100..131}; do convert -scale 25% CIMG00$i.gif CIMG00$i_scaled.gif; done # works not it seems the system is working for about half a minute, but I get no output. The single command
Code:
convert -scale 25% CIMG100.gif CIMG100_scaled.gif # works
works as expected and gives me a scaled image. What does the convert command do in the second case? is the for-loop wrong?
my issue is that the when i put in the correct input its going into the loop like i put in incorrect input and wont break out of the loop even with the correct input entered
The script that Iam trying to write is running a for loop and reading line by line from a text file. inside this for loop i would like to execute update SQL statement .
a pesudo code is Quote: `$ISQL -U $username -P $Password -D $Dbname -I $INTERFACE <<QRY for id in $idlist #idlist iam reading from a file