tags:

views:

56

answers:

3

I need to put several thousand large files in a folder into a RAR archive several times a day. I used to do this manually via sFTP using a custom command with the RAR software package.

I'm wondering if it would be possible to use the RAR command using system() in PHP, and bring back the results every second or so to get a clear indication of how far along the process is.

When you use the RAR command, it draws a progress bar in the terminal window much like wget. I want to grab that progress bar and somehow display it on a page.

Any ideas on how I could do this?

Thanks :)

+3  A: 

You can use the PHP popen() call to execute a process and read its standard output. That will get you the progress bar. However, using the PHP builtin rar support might get you a more robust solution with better information on what went wrong and why.

Variable Length Coder
From what I can see from the builtin PHP rar support, it only supports extracting RAR files and not archiving them, which is what I need to do.Thanks for the link, though, it'll be helpful for something I need to do later on down the line :)
Whitey
A: 

if you stick with system() then the best you can do is get the return code back from the process. Find out what the return code is for success. Use it to determine if your operation was, in fact, successful.

If you use exec() or passthru() you can get the output of the command as well.

You might be able to get the progress bar using some magic with popen(), but I am not sure.

Chris Kloberdanz
A: 

Yes may be popen() is useful. You can get the output and parse it to get the results.

Enjoy coding