Filtering terminal commands on linux

Adriaan Renting renting at astron.nl
Fri Aug 5 10:06:51 EDT 2005


Thank you very much for you answer.
We are using gear for a couple of reasons, the most improtant being that
we use it in a production environment and it's the only package with
commercial support under Linux that supports Dual Layer DVDs. (at least
according to the person that made the decision to use it)
We've had trouble in the past with cdrecord/dvdrecord.

_I am_ using the batch mode, but still need to be able to parse the
interactive output, as it will stop and try to communicate with the
user, if it encounters a problem.
It's batch mode isn't more sophisticated as "gear < batchfile".


Adriaan Renting        | Email: renting at astron.nl
ASTRON                 | Phone: +31 521 595 217
P.O. Box 2             | GSM:   +31 6 24 25 17 28
NL-7990 AA Dwingeloo   | FAX:   +31 521 597 332
The Netherlands        | Web: http://www.astron.nl/~renting/
>>> "Lonnie Princehouse" <finite.automaton at gmail.com> 07/29/05 9:38 PM
>>>
>Firstly, there's probably a better way to do whatever you're >trying to
>do w.r.t cd/dvd burning.  I'm not familiar with gear, but its >webpage
>lists "Batch file scripting capability" as a feature, which >suggests
>that you might be able to do what you want without parsing >output
>intended for humans.  There are also a multitude of >command-line cd
and
>dvd utilities for Linux which might be better for scripting.
>
>That said, it shouldn't be too hard to craft a regular >expression that
>matches ANSI control sequences. Using
>http://www.dee.ufcg.edu.br/~rrbrandt/tools/ansi.html as a >reference,
>here's how to do this for the first few control sequences...
>
>esc = '\x1B'
>start_control_sequence = esc + '['
>
>Pn = r'\d+'     # Numeric parameter
>Ps = '%s(;%s)*' % (Pn,Pn)   # Selective parameter
>PL = Pn
>Pc = Pn
>
>control_sequences = [
>    PL + ';' + Pc + '[Hf]',     # Cursor position
>    Pn + '[ABCD]',              # Cursor >up|down|forward|backward
>    's',                        # Save cursor position
>    'u',                        # Restore cursor position
>    '2J',                       # Erase display
>    'K',                        # Erase line
>    Ps + 'm',                   # Set graphics mode
>    '=' + Pn + '[hl]',          # Set|Reset mode
>    # ... etc
>]
>
>match_ansi = re.compile(start_control_sequence +
>    '(' + '|'.join(control_sequences) + ')')
>
>def strip_ansi(text):
>    return match_ansi.sub('',text)
>
>
>(note: code is untested.. may contain typos)

-- 
http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list