473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

removing terminal control characters

i'm trying to display output from a linux command line program and i'm
getting a lot of junk.
i was told that pulling out escape sequences like this regex: \033[^;]*;
would do it but that doesnt catch them all. i'm seeing the little box
characters for instance.

the only way i've found thus far is this:

building the regex object:
regex = re.compile(r'\033[^;]*;')
then passing each line of output through this:
line = regex.sub("",line)
junk = line.translate(identity, string.printable)
line = line.translate(identity, junk)

i know there must be a better way!
is there a way to get a non-printable group of characters to search
for?

thanks,
aaron kunkle

Jul 18 '05 #1
1 3192
Aaron,

Have a look at "Text Processing in Python," by David Mertz.
Wonderful book, just bought it from Amazon.com

Here is a link to the soft copy.
http://gnosis.cx/TPiP/

Cheers,

--Alan

Aaron Kunkle <aa***@brokensociety.com> wrote in message news:<ma**********************************@python. org>...
i'm trying to display output from a linux command line program and i'm
getting a lot of junk.
i was told that pulling out escape sequences like this regex: \033[^;]*;
would do it but that doesnt catch them all. i'm seeing the little box
characters for instance.

the only way i've found thus far is this:

building the regex object:
regex = re.compile(r'\033[^;]*;')
then passing each line of output through this:
line = regex.sub("",line)
junk = line.translate(identity, string.printable)
line = line.translate(identity, junk)

i know there must be a better way!
is there a way to get a non-printable group of characters to search
for?

thanks,
aaron kunkle

--

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: LRW | last post by:
I manage our mySQL database through putty (SSH terminal client). And whenever I do a select * from the table that contains ENCODEd passwords, the funky characters do funky things with the display....
3
by: Josh Schmidt | last post by:
How can one set the terminal services profile and home directory path in AD using VB.NET? I can set the usual profile paths, but terminal services properties are not supported with ADSI. Any...
8
by: Peter O'Reilly | last post by:
I have an HTML form with a textarea input box. When the user conducts a post request (e.g. clicks the submit button), an HTML preview page is presented to them with the information they have...
1
by: Adriaan Renting | last post by:
I have the problem that I need to interact with a CD/DVD burning program called gear. I do this by running it in a pseudo terminal. I also need to log what I'm doing, so I copy all output I get...
2
by: Jacob Kjaergaard | last post by:
Hi! Im looking for a (relatively) easy way to print at the same spot on the terminal. Like i.e wget does when showing the progressbar and the percentage of the download. if been looking in...
6
by: Terry Olsen | last post by:
I need to make a terminal window to emulate special characters of a vintage PC. I don't think I can use a console because you can't change its font...can you? So what is the best way to make a...
7
by: Captain Dondo | last post by:
I'm working on a terminal emulator for an embedded system. The key requirements are small size, code clarity, maintainability, and portability. We have machines that regularly see a service life...
13
by: sayansayan | last post by:
two threads are running in a prog i need the output of one thread in a new terminal which the prog will create and the output of other thread in the old terminal
2
by: David | last post by:
Hi list. I've never used unicode in a Python script before, but I need to now. I'm not sure where to start. I'm hoping that a kind soul can help me out here. My current (almost non-existant)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.