I am going to
- initiate download (scp user@remote.computer.com/tmp/file /backup/) from a web browser
- ajax (could be jQuery) the request to web server (suse)
- where php will run the scp command
Is there any way that user could see the scp download progress bar in the browser?
Not without a lot of messing around.
Of the top of my head you could redirect the output of SCP to a file, then have an AJAX request to a script that parses that file, and when a new line appears (assuming scp increments it’s progress bar by seperating lines with \r) the PHP script exits in some way that instructs the browser to increment it’s progress bar, then initiate the AJAX process again… and so on until scp terminates.
I have done stuff like this before, and I would say that it’s not worth the massive effort for such a small nicety – unless you feel you don’t have enough to do already…
It would be much easier to do stuff like this if browsers would let you read
ajax.responseTextbeforeajax.readyState == 4, but they don’t, so it isn’t.EDIT
Just thought of an alternative approach to this that might be easier in some ways but more difficult in others:
If you put the progress bar in an
<iframe>you wouldn’t need to have the huge number of AJAX calls, and you could do it all by server-pushing javascript – but you will need a web server that supports this, and are somewhat relying on a browser that will handle the setup sensibly.