The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do I calculate percentage ? the_learner High Level Programming 6 04-18-2007 01:40 PM
how to make percentage of a running script? jimmbp Shell Programming and Scripting 1 01-31-2006 10:41 AM
Computung Percentage preetikate UNIX for Dummies Questions & Answers 2 02-09-2004 06:13 AM
percentage sign in a drive mapping ? simon2000 UNIX for Advanced & Expert Users 2 09-17-2002 09:30 AM
How can I get a processor's CPU Percentage? sangjinn High Level Programming 2 10-16-2001 10:31 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-17-2008
Registered User
 

Join Date: Jan 2008
Posts: 172
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
how to get the percentage of completion? during a copy!

Hi all,
I would like to know how to introduce that progress bar or the %of completion during copy of files...

In the sense,I am copying a few files onto RAM at the boot time....
These 2 files combined take about 550mb of ram,so instead of just having a blinking cursor till the copy is over,i thought of giving a percentage of completion value...
But how do i do that?
How to get that ,1%......10%......100%..
Something like this!!

Pls advice!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-18-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,253
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Some slow commands offer a hook to let you know how far they are getting. What are you using to copy the file?

Some versions of dd will report the transfer rate (the same report you get at the end) when you send them a SIGUSR1. So you could use dd to copy and signal it, say, once per second to get a progress report. Post-process it in your script to turn it into something user friendly.
Reply With Quote
  #3 (permalink)  
Old 05-18-2008
Registered User
 

Join Date: Jan 2008
Posts: 172
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
i am using cp to copy the files!!!!

Can you specify accordingly...
the reason is at the point in time when this copy is being made, the dd binaries are not loaded so i will have to do some extra work to get these as well..
So i would appreciate if we can keep the cp and yet provide some sort of user readability!!!

thanks
Reply With Quote
  #4 (permalink)  
Old 05-18-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,253
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Welp, unless your version of cp has hooks for this, the best you can do is guess. It's probably more aggravating than helpful if the guesstimated remaining time is completely off base, so perhaps it's just better to display a spinning cursor.

You could copy a smaller file first to calibrate, and then extrapolate a time estimation from that, but what if the disk gets jammed or another process accesses the disk at the same time?

If you don't have dd, chances are any useful tools for cobbling together some eye candy won't be available either ... (I'd be hoping that dd is available if cp is, though.)

Another approach would be to run cp in the background and watch the size of the destination file, and calculate a percentage from that. I'd be nervous about putting cp in the background and lose on error checking etc just to get some pretty text on the screen, though.
Reply With Quote
  #5 (permalink)  
Old 05-18-2008
Registered User
 

Join Date: Jan 2008
Posts: 172
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Thanks for the info,...
However the cp was not there in the ramdisk either,I had to relocate the binaries of cp frm another suitable OS then i was able to use it...
So i will have to do the same with dd as well...
How ever i am not familiar with dd...
So if you could give me the command line of dd?

and also if i use dd,how may i have the privalage of getting the %

Thanks!
Reply With Quote
  #6 (permalink)  
Old 05-18-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,253
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
On second thought, I'm not sure it's any better than cp and monitoring the size of the destination file.

Anyway, before you invest heavily into it, check that your version understands SIGUSR1 -- not all of them do.

dd has a notoriously iffy syntax. In fact I read somewhere that it was meant as a joke on the perversity of another syntax (JCL if I recall correctly) but somehow it just stuck.

Code:
dd if=/path/to/input/file of=/path/to/output/file
Optionally spice it with a bigger block size (bs=8192 perhaps).
Reply With Quote
  #7 (permalink)  
Old 05-23-2008
Registered User
 

Join Date: Mar 2008
Posts: 17
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
well, there is this:
Lamby’s Blog “Can you get cp to give a progress bar like wget?”
Reply With Quote
  #8 (permalink)  
Old 05-23-2008
Registered User
 

Join Date: Jan 2008
Posts: 172
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
The link youve provided is great but strace causes overhead,esp if the file is huge...
The file am copying is about 500mb and at boot time this will increase the time by a lot of secs.....

I have however written a new script following up on the links that you have provided and from bit of surfing of my own....

Pls have a look at it, its in the next post!!
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
"inappropriate ioctl for device" 421 service not available, remote server has closed connection ^m autosys awk trim bash eval bash exec bash for loop boot: cannot open kernel/sparcv9/unix close_wait command copy/move folder in unix curses.h cut command in unix dead.letter find grep find null character in a unix file grep multiple lines grep or grep recursive grep unique inaddr_any inappropriate ioctl for device lynx javascript mailx attachment mget mtime perl array length ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp batch sftp script snoop unix stale nfs file handle syn_sent tar exclude unix unix .profile unix com unix forum unix forums unix interview questions unix mtime unix simulator unix.com vi tab size vi+substitute+end+of+line+character while loop within while loop shell script


All times are GMT -7. The time now is 12:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101