How about using find:
echo Extracted `find ./ -type f | grep -c ^` files so far |
Quote:
Thank you very very much |
To see how many files are in a tar archive:
Code:
MAX_NR=`tar -tzf 1.tar.gz | wc -l` Code:
NR=0 |
Quote:
thanks once again |
Quote:
My destination directory is /tmp/install-debian i.e. this is the directory in which I am extracting my files from the tar ball. Also david, for your suggestion of : Code:
find ./ -type f | grep -c ^ thanks guys for helping me out. |
directory is the absolute path to the directory for which you wish to see how many file are in it.
The command "find directory" lists all the files in the directory, and subdirectories. The command "wc -l" prints the number of lines it receives. The "|" (pipe operator) connects the first command output to the second command input. The second command finds all the files in the current directory (-f switch), and counts them (-c is for count, and as far as I remember ^ for grep is end or start of line). |
Thanks vladmihaisima and David. It worked. Thank you very very much.
It was good to learn how to get the progress bar for different commands. Guys finally I have one more questions. As I told before I have been using other commans also in my script which takes 30-40 seconds to execute. For Eg. one command is: Code:
/sbin/grub --no-floppy --batch 1>/dev/null <<EOF Code:
mke2fs -j -T news /dev/hdd1 1>/dev/null 2>&1 Code:
fsck -f -a /dev/hdd1 1>/dev/null 2>&1 Also, it would be a good idea if anyone can suggest a general way of implementing progress bar irrespective of the command given. Guys thank you once again for all your effort and time. |
Any one please?
thanks |
I don't think there could be a general way, unless each command provides some kind of feedback. And of course this would introduce a (usually small) performance penalty on the command - and for this reason some people will see this as a bad thing to do.
And about your 3 specific comands I really have no idea how to determine their progress. (and now a Microsoft type idea : you could show a progress bar based on an estimation and that will remain at 99% until the command finished :D - just kidding ). |
Quote:
I try to run this script over putty. But it seems to blink alot when progress meter update. Is there anyway i can make it run without screen blinking? besides , when i resize my putty screen, the meter is gone and i back to command prompt.. Is there be any work around of this issue? |
I spent a lot of time on just such an idea. The algorithm for determining the percentage winds up taking lots more cycles than it was worth and is not very dependable.
You can maybe use tar to get the estimated size of the uncompressed files. Then as the file is uncompressing you keep checking the used disk space with df and comparing that to the full estimated disk space needed. You need to also take into account the speed of the machine and devices being used so you need to also time the unpack process for a given quantity so you can estimate the finish time. Using progress-bar is similar to guage, excpet that progress bar expects a pulsed input -usually a series of dots which are ouputted by the program as it runs. I'd suggest you download the sources for Xdialog as it has some very good examples and the syntax is nearly the same for most widgets. The slackware installation and configuration utilities are good examples of pure dialog. |
for my case, i have a large file (100G over) to copy. I don't want to the backup operator remote desktop session. So , i would prefer commandline dialog. I have downloaded the slackware11 but not sure which file to look for the installation & configuration dialog? Can you tell me which file to look up (for checking how they do dialog properly).
thanks |
Probably easier to dig around in the sources for Slackware and just download what you need there.
The package called pkgtools is a good place to start. If you got the installation CD#1 the initrd conatins the installation routines which are written in dialog. |
I have a new problem about keyboard now. My dialog UI easily abort if user press F1~F4 or number pad key.
I look up the 'setup' script in slackware but it doesn't have anything on that script to stop user keyboard input to abort the menu. When i press ESC key on the "no linux partition detect" message box, it simply blink. Can anyone tell me how to achieve so? I don't want user to accidentally drop off from my UI to command prompt. |
i guess i have to use while loop to prevent dropping off from UI...
|
All times are GMT -5. The time now is 09:23 AM. |