I have a requirement where in which I have to mail an output from multiple programs in the same colour as the output from shell script.
I have seen a post to mail html in our forum,but my case is I have to first identify which colour the output is in an then mail it to in the same color ,guys please help me this question has become more of a conundrum to me .
Regards
Kingcobra
---------- Post updated 03-23-14 at 12:11 AM ---------- Previous update was 03-22-14 at 09:37 PM ----------
I can convert the text to html,by where I am struck is that I need to retain the color;all of us are aware that with default settings in ubuntu directories will be in blue color however when I convert and mail the content taht will be plain white;please help me finding the answer to this question
Last edited by Scott; 03-22-2014 at 01:47 PM..
Reason: Please use code tags
If I am reading your post correctly then you are looking for the attributes to a string/character at any random part of an echo to a terminal.
This can't be done so you have no choice but to do it manually.
The terminal emulator has no concept of BIOS interrupt (0x)10, subcommand (0x)08, IIRC, so you will have to hard code each line of your listing yourself.
I am not sure how much easier it would be to hard code each complete line listing in the corresponding colour(s) but could be an alternative to look at something like this...
This User Gave Thanks to wisecracker For This Post:
Thanks wisecracker for your reply,the actual requirement in our project is that we have a java program that prints text to the terminal when manually run and red when printed in all instances is an error,our requirement is that we need to send an email whenever red is outputted.
Now this check is being done manually we are planning to convert to cron tab and divert this output to a file and mail in cases only when file has anything in red color.But the problem here is when I redirect I am lossing the colors
---------- Post updated at 08:12 PM ---------- Previous update was at 08:10 PM ----------
In short the question is how do the retain color when text is redirected to a file.
Thanks mate for your reply,however the shell script I am executing does not have --color option,its a custom script written which is printing colors using awk and echo
Since ls has --color options that works fine but what if a custom script does not have color option,Thanks
Well using ls was just an example, the reason --color is needed for the ls command is that it normally detects that the output isn't a terminal and avoids outputting any color escape sequences. This is probably to simplify scripts that process the ls output.
Now unless your custom script has a similar feature i.e checking stdout and only outputting plain text when it's not a terminal this should all be fine.
Checking this script ansi2html.sh script it does require python, however it should be a pretty trivial exercise to change it to use awk instead.
Edit: Re-reading your posts I'm guessing your script does check the output type and only print the color escape sequences if the output is a terminal. It's probably checking [-t 1] or something similar. I've encountered this issue before myself and found using ssh is a nice workaround.
Say your script is called output_color then you could call it like this:
or using ls and an example:
Last edited by Chubler_XL; 03-24-2014 at 10:12 AM..
This User Gave Thanks to Chubler_XL For This Post:
Hi All,
I have a file that contains following entries.
I want to highlight the line that has word as "FAILURE" while sending the email.
File
------------------------------------------------------------
Job Name: ABC
Start Time: 07/20/2019 07:32:39
End Time: 07/20/2019... (4 Replies)
Hello,
I am using RHEL 6.1 on VMware
I am searching for a way to change background color (not line by line color wich one can using tput command)
basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)