473,804 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Coloring print lines

Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..

--SV

----Thanks in advance.
Jul 18 '05 #1
5 20851
Sami Viitanen enlightened us with:
Is there an easy way to make script print text with differents colors to
screen (shell)?
Sure, just use ANSI codes.
I mean a script that can for example print lines in red if some
error occurs in executing some information..


Example:

print "\033[31;1mError:\033[0m some message"

Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Jul 18 '05 #2
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..

--SV

----Thanks in advance.

If you're using python at X, best advice I canv give is Text-widget at
Tkinter and RTFM (sorry couldn't resist temptation :) . Otherwise you
probably have to fiddle with curses-library (unix-only).

Best way to gather information of execution is to open log-file, code
couple of monkeys and let them crack system as much as possible. This is
only my opinion. Coders are blind to their mistakes even at testing.

Jul 18 '05 #3

"Risto Peränen" <no@more.spam.p lea.se> schrieb im Newsbeitrag
news:bi******** **@mordred.cc.j yu.fi...
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?
.... If you're using python at X, best advice I canv give is Text-widget at
Tkinter and RTFM (sorry couldn't resist temptation :) . Otherwise you
probably have to fiddle with curses-library (unix-only).


Some month's ago Adam Vandenberg released some alpha curses for Windows

http://flangy.com/dev/python/curses/

I worked with my Win2000 but is only a partial implementation. It has some
color support that migth suffice for the request of the OP.

Kindly
Michael P

Jul 18 '05 #4
| Is there an easy way to make script print text
| with different colors to screen (shell)?
| ...

Sami ...

I have a couple of small examples for printing
colorized strings via Ansi escape sequences
from Python under Windows ...

http://fastq.com/~sckitching/Python/ansi_strings.zip

--
Cousin Stanley
Human Being
Phoenix, Arizona
Jul 18 '05 #5
Sami Viitanen wrote:
Hello,

Is there an easy way to make script print text with differents colors to
screen (shell)?

I mean a script that can for example print lines in red if some error occurs
in executing
some information..


IPython (http://ipython.scipy.org) supports coloring for its own purposes, and
comes with a module for this. You can simply import this module and use it for
your programs. Besides, you may like ipython itself ;)

Cheers,

f.
Jul 18 '05 #6

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

Similar topics

2
14688
by: Wow | last post by:
Do I have to replace all new lines with \n and document.write one line? Is there something like perl's print lines print << 'body'; body in javascripts?
5
5828
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting attachment to the email consistently does not display all of the lines it should in one of the GroupFooters. I am using the Print event in the report to print lines multiple times in a groupfooter depending on an integer set elsewhere in the VBA...
6
5542
by: Melissa | last post by:
Does anyone have a generic procedure for adding blank lines to reports like Sales details, PO details and/or Orders details. The procedure would need to count the number of line items, determine the remaining page to fill and print blank lines with the same number of fields as the line items. In addition, if there were a long list of line items that carried over to a second and possibly more pages, to print blank lines at the last page. The...
7
4806
lee123
by: lee123 | last post by:
hey ( killer42 ) hi there, im programing in vb 6 and i want to make lines on a invoice i created in vb6 but don't know how i would go about doing that.. i have everything layed out to print (codes) but no lines to separate the orders from one another, it doesn't look good the way it is i would like the lines in there as well lee123
4
1701
by: ramaswamynanda | last post by:
Hello, I have an application in Access where I have developed about 10 reports. These have been working for a while and produce data properly. I recently tried exporting the report, from the print preview mode to MSWord. The lines on the report do not print at all. The lines also do not print, if i take a report. I have checked the line proeprties and they are Border style = solid special effect = flat border width = at some places...
12
1886
by: rajash | last post by:
Thanks to everyone on this forum for their helpful comments, now here is my solution to Exercise 1.17, pretty short and neat! // print lines longer than 80 chars char x; // allocate buffer void main() {
3
2673
by: lilly07 | last post by:
I am new to perl. I would like to open a file and print 2,6,10,14.. etc lines of that file content. How to do it? I amm able to open a file and print the contetnts as below: #!usr/bin/perl $data_file = "test.txt"; open(EXPORTFILE, $data_file) || die("Could not open file!"); print "Opened $data_file\n"; $counter = 0; while(($line=<EXPORTFILE>) && ($counter<100)) {
3
1881
by: Anja Friedrich | last post by:
Hi all, I have another question. I have an array sorted like this: small_motif_a 1853 1863 small_motif_a 1970 1980 small_motif_a 1971 1981 small_motif_b 789 799 small_motif_b 882 892 small_motif_b 1181 1191 small_motif_b 1193 1203
15
2325
by: Chocolade | last post by:
public void logger_reader(string logger_reader) { string item = @"Last"; //*** Coloring all the text inside the richTextBox1 in Red ***\\ string ftext = File.ReadAllLines(logger_reader); for (int i = 0; i < ftext.Length; i++) { richTextBox1.SelectionColor = Color.Red; richTextBox1.GetFirstCharIndexFromLine(i); ...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10354
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10101
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9177
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6870
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.