How to obtain the unrar overall progress report?

2008-09-13 Thread Dan Thurman


I am using fedora's "native" unrar for my python
application - no dll version or whatever else is out there.

I have been trying to figure out how to obtain
unrar's overall progress report for inclusion into my
python code but so far I have not been successful.

I tried to turn off all of the comments except for
the progress report and all I have so far is:

unrar x -ierr +o- $file | sed -e 's/.*\([0-9]\+\)[%]$/\1/

I have tried: -c-, -inul, and many other switches but
none of these switches helped.

There is also a -id[c,d,p,q] command line
option but this does not seem to work and this is
option is not discussed in the man pages.

I noticed that if I add 2>&1 before the pipe,
but this removes the overall progress report
and shows only the results on a per-directory/file
results, which is not what I want.

I have also tried awk but unable to figure out how
to do it.

The problem I have is getting rid of the per
directory/file reports when all I want is the overall
progress report, 1-100%.

Any advice?

Thanks-
Dan

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: How to obtain the unrar overall progress report?

2008-09-13 Thread Patrick O'Callaghan
On Sat, 2008-09-13 at 12:29 -0700, Dan Thurman wrote:
> I am using fedora's "native" unrar for my python
> application - no dll version or whatever else is out there.
> 
> I have been trying to figure out how to obtain
> unrar's overall progress report for inclusion into my
> python code but so far I have not been successful.
> 
> I tried to turn off all of the comments except for
> the progress report and all I have so far is:
> 
> unrar x -ierr +o- $file | sed -e 's/.*\([0-9]\+\)[%]$/\1/
> 
> I have tried: -c-, -inul, and many other switches but
> none of these switches helped.
> 
> There is also a -id[c,d,p,q] command line
> option but this does not seem to work and this is
> option is not discussed in the man pages.

Perhaps if you give us a sample of output from the command (without the
sed filtering) someone can come up with something. Just a few lines
please, including any header lines.

poc

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: How to obtain the unrar overall progress report?

2008-09-13 Thread Patrick O'Callaghan
On Sat, 2008-09-13 at 13:09 -0700, Dan Thurman wrote:
> # unrar x -ierr -o+ ~dant/Desktop/foo.rar \
> | sed -e 's#\([0-9]\+\)[%]$#\1#'

As I said, please send the output *without* enabling the 'sed' filter.

Hint: use 'head', e.g.:

# unrar x -ierr -o+ ~dant/Desktop/foo.rar| head 20 > capture

poc


-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: How to obtain the unrar overall progress report?

2008-09-14 Thread Patrick O'Callaghan
On Sun, 2008-09-14 at 07:05 -0700, Dan Thurman wrote:
> Patrick O'Callaghan wrote:
> >
> > On Sat, 2008-09-13 at 13:09 -0700, Dan Thurman wrote:
> > > # unrar x -ierr -o+ ~dant/Desktop/foo.rar \
> > > | sed -e 's#\([0-9]\+\)[%]$#\1#'
> >
> > As I said, please send the output *without* enabling the 'sed' filter.
> >
> > Hint: use 'head', e.g.:
> >
> > # unrar x -ierr -o+ ~dant/Desktop/foo.rar| head 20 > capture
> >
> # unrar x -ierr -o+ ~dant/Desktop/foo.rar | head 20 >  capture
> head: cannot open `20' for reading: No such file or directory

Oops, should be "head -20"

> -rw-r--r-- 1 root root 0 2008-09-14 06:15 capture
> 
> # unrar x -ierr -o+ ~dant/Desktop/foo.rar | head -n 20 >  capture
> -rw-r--r-- 1 root root 0 2008-09-14 06:20 capture
> 
> # unrar x -ierr -o+ ~dant/Desktop/foo.rar 2>&1 | head -n 20 >  capture
> =
> UNRAR 3.71 beta 1 freeware  Copyright (c) 1993-2007 Alexander Roshal
> 
> 
> Extracting from /home/dant/Desktop/foo.rar
> 
> Extracting  foo/cd1/Track01.flac ^H^H^H^H  0%^H^H^H^H^H  OK  
> Extracting  foo/cd1/Track02.flac ^H^H^H^H  0%^H^H^H^H  1%^H^H^H^H  
> 2%^H^H^H^H  3%^H^H^H^H  4%^H^H^H^H^H  OK  

The problem is that there are multiple progress numbers for each output
record. That's why the usual filters such as 'sed' are going to have a
hard time of it. You need to capture each number as it comes out and
process it (throwing away the ^H i.e. backspace characters) even though
you haven't seen a newline yet, because by the time you see the newline
the file has finished.

(This is a clear indication that the program was originally written for
a non-Unix environment, since the author just assumes that the progress
is for display on a terminal and not for filtering).

I'm not saying it's impossible, just nasty. You might be better tweaking
the source of unrar to give you more manageable output. You probably
can't distribute the result though (the license is freeware, not free).

poc

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines