Is there a way to poll the cp command to get its current progress? I understand there's a modified/Advanced copy utility that adds a small little ASCII progress bar, but I want to build my own progress bar using led lights and whatnot, and need to be able to see the current percentage of the file activity in order to determine how many LEDs to light up on the progress bar.
Asked
Active
Viewed 806 times
0
-
You might have better luck asking this on http://raspberrypi.stackexchange.com/ or http://unix.stackexchange.com/ – The Guy with The Hat Jun 15 '14 at 19:29
-
1For `cp` itself, `-v` is probably the best you'll get. Try doing `stat` on the destination files periodically. – glenn jackman Jun 15 '14 at 19:32
-
None of the base cp utilities support 'polling for progress', as Glenn mentions, the `-v` option is the only mechanism it has by default. – Anya Shenanigans Jun 15 '14 at 19:33
-
1Exactly. You know the size from the original file. Stat the destination file and do the math and you have your progress. – Duck Jun 15 '14 at 19:34
-
possible duplicate of [How can I make a progress bar (cp copying a directory)?](http://stackoverflow.com/questions/7128575/how-can-i-make-a-progress-bar-cp-copying-a-directory) – Reinstate Monica Please Jun 15 '14 at 19:37
3 Answers
1
you can use rsync, which can be used pretty much like cp is used, but offers an option for progress indicator. It is sent to standard out, and you ought to be able to intercept it for your own fancies.

Deleted User
- 2,551
- 1
- 11
- 18
0
cp
does not have this functionality. You have to use some other tool, for example pv
(pv foo.img > bar.img
). pv
is available at http://www.ivarch.com/programs/pv.shtml.

Christian Berendt
- 3,416
- 2
- 13
- 22
0
Make a simple python script what will do the copy task and after every N copied block simply do whatever you want. (e.g. script your rpi leds)
See also:
- Recursively copying files with progress
- How to copy a file in Python with a progress bar?
- https://www.google.com/search?client=safari&rls=en&q=python+file+copy+progress+indicator&ie=UTF-8&oe=UTF-8
:)