Here is how I would do it:
- Fork a child to run the SCP (or other file transfer) process and exit.
- From the parent, loop on the following:
- Is the child done? If so, set progress = 100% and exit loop.
- Set progress = current_filesize / full_filesize.
- Sleep for N seconds.