473,396 Members | 1,945 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,396 software developers and data experts.

File output using colour

Hi Experts,

I am interested in creating some Report files for that using below lines of perl
code to display out put in colour to distinguish different types of Errors

use Term::ANSIColor;
print color .........etc


similary is there any possibility to dump the content to a file in UNIX platform using PERL so that when it is opened it should display information in colours

Thanks & Regards
Sarma
Apr 12 '07 #1
8 5713
tifoso
41
Why not print to an html file that way the coloring is straighforward

#...
print "<html><body>..."; etc
...
print "<font color=-red> Massive ERROR</font>";
....

if the perl is run from a web-page you can pop-up a page
with your results, don't forget to add
print "Content-type: text/html \n\n";
at the top

Ciao
Apr 12 '07 #2
KevinADC
4,059 Expert 2GB
Hi Experts,

I am interested in creating some Report files for that using below lines of perl
code to display out put in colour to distinguish different types of Errors

use Term::ANSIColor;
print color .........etc


similary is there any possibility to dump the content to a file in UNIX platform using PERL so that when it is opened it should display information in colours

Thanks & Regards
Sarma
You would have to decide what type of UNIX file format to use that understands color and write the file in that format so when it's opened the application that reads the file knows how to display the embedded markup instructions. Decide on a file format and search CPAN to see if there is a perl module that writes files in that format you decide to use.
Apr 12 '07 #3
Hi Kevin,

how to use the CPAN modules the reason is some time back i wanted to create and dump data to excel sheet instead of normal UNIX file so i gone through the help information on how to use the CPAN modeules in the net but when i download i realize i don't have permissions to add that module to the perl installer so regarding this also this will not help me

except this CPAN can u suggest me some other simple approach to dump into the file which i can open using vim or vi editors


Best Regards
Kiran Kumar
Apr 13 '07 #4
KevinADC
4,059 Expert 2GB
Do you know how to print anything to a file? Thats all you need to do, then open the file with what ever editor you want. But you said you wanted colorized output. For that you have to know how to write the color information into the file. I don't know how off the top of my head. And it depends on the file format you will be using. If it's just plain text you can't include color information or any other stuff besides spaces, tabs, or newlines.
Apr 13 '07 #5
miller
1,089 Expert 1GB
Hello Kiran Kumar,

The best advice that I can give you is to not try to do this.

If you want to create reports that differentiate between different levels of errors, then give those errors different labels. For example the Apache::Log module has 8 sequential log levels: emerg, alert, crit, error, warn, notice, info, debug. It is possible to set the current log level of the server so that logs of a certain less critical level are not recorded. And in the log file, all messages of a specific type are prefixed with that type label.

It is true that you can create pretty colours, but this requires specific knowledge on how to read them. It is a much better practice to stick with a standard file format such as plain text or html as new people will know how to read it. Besides, having color implies that you'll have to have some type of legend to translate what it means, where as having a label makes it more inherantly obvious.

That's all my advice concerning this subject,
- Miller
Apr 13 '07 #6
KevinADC
4,059 Expert 2GB
That's all my advice concerning this subject,
- Miller


heheheh.... you sound like Forrest Gump ;)
Apr 13 '07 #7
miller
1,089 Expert 1GB
heheheh.... you sound like Forrest Gump ;)
hehe :)

Yeah, at one time (almost 7 years ago) I also looked into adding colour to some of my terminal scripts. I eventually figured out why this is a foolhardy thing to do. There are much better methods for making reporting easy on the eyes. Preferably ones that are less prone to errors of their own.

- M
Apr 13 '07 #8
Miller,
Thanks for your suggestion coming to this i am new to CPAN related stuff but anyway i got there is tar.gz kit available to install it , is it ok if i install only in local directory/path or has to be installed in root directrory where entire perl package installed , if it needs 2nd option then i don't have previliges so it will stop me using this package

the reason i asked colour dump into ASCII file is to distinguish various statements not only for displaying error data (let us say if it is not an error or warning from any output but wanted to distinguish the output information dumped into a normal ASCII file to be opened by vi editors based on some catogery )

It is great help if you can provide help information on installation or the link where can i get suc info
Thanks
Kiran
Apr 17 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
3
by: Herman | last post by:
Hi everyone, I have a multiple file project for a class assignment. It consists of a class Point, then a class Polygon which uses the Point object, then a class Picture that uses the Polygon...
7
by: Krista Bailie | last post by:
I'm sure this is so easy that it will hurt for anyone to read it, but I really need some direction. I'm trying to create a color chart (RGB) that shows steps between two different colors as...
3
by: Andreas Palsgård | last post by:
Hey there... I hope someone can help me with my problem. I want to write a class object with both strings and integers, to a file, and be able to read it properly again. I thought that the code...
25
by: madsgormlarsen | last post by:
Hi I am making a tab menu with css, and the tabs changes color depending on wich tab is current. 1. I could load a different css file for each tab/color. 2. I could do some inline css only...
3
by: ryanbreakspear | last post by:
Hi, I've been doing a bit of reading on the Internet, but can't work out what is the best way to load an XML file into a table. The XML file is normalised, so for each record I create in my...
7
by: B. Williams | last post by:
I wrote a program that would simply output data to the screen, but now I am trying to have the data saved to a file. I don't have a problem creating the file or even outputting data to it when there...
9
by: colin | last post by:
Hi, I have all the components of a .bmp file in memory wich i need to write to a .bmp file, (or other convenient image file) ie i have 256 color pallete of RGBquads and array of 8bit pixels, I...
41
by: biplab | last post by:
Hi all, I want to read the pixel values of a .bmp image(which will be input to the code) into a matrix...plz help me out as i can not understand how to achieve this... thanks in advance ...
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: 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
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
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.