Sponsored Content
Top Forums Shell Programming and Scripting Identify Color and send email with same color Post 302894179 by Chubler_XL on Monday 24th of March 2014 08:58:54 AM
Old 03-24-2014
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:

Code:
$ ssh -t localhost /usr/local/bin/output_color | ansi2html.sh > king.html

or using ls and an example:

Code:
$ ssh -t localhost "cd $PWD; ls" | ansi2html.sh > king.html


Last edited by Chubler_XL; 03-24-2014 at 10:12 AM..
This User Gave Thanks to Chubler_XL For This Post:
 

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

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)
Discussion started by: Dexobox
2 Replies

2. Shell Programming and Scripting

Send mail with font color change

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)
Discussion started by: sdosanjh
4 Replies
Imager::Color::Float(3pm)				User Contributed Perl Documentation				 Imager::Color::Float(3pm)

NAME
Imager::Color::Float - Rough floating point sample color handling SYNOPSIS
$color = Imager::Color->new($red, $green, $blue); $color = Imager::Color->new($red, $green, $blue, $alpha); $color = Imager::Color->new("#C0C0FF"); # html color specification $color->set($red, $green, $blue); $color->set($red, $green, $blue, $alpha); $color->set("#C0C0FF"); # html color specification ($red, $green, $blue, $alpha) = $color->rgba(); @hsv = $color->hsv(); # not implemented but proposed $color->info(); DESCRIPTION
This module handles creating color objects used by Imager. The idea is that in the future this module will be able to handle color space calculations as well. A floating point Imager color consists of up to four components, each in the range 0.0 to 1.0. Unfortunately the meaning of the components can change depending on the type of image you're dealing with: o for 3 or 4 channel images the color components are red, green, blue, alpha. o for 1 or 2 channel images the color components are gray, alpha, with the other two components ignored. An alpha value of zero is fully transparent, an alpha value of 1.0 is fully opaque. METHODS
new This creates a color object to pass to functions that need a color argument. set This changes an already defined color. Note that this does not affect any places where the color has been used previously. rgba() This returns the red, green, blue and alpha channels of the color the object contains. info Calling info merely dumps the relevant color to the log. AUTHOR
Arnar M. Hrafnkelsson, addi@umich.edu And a great deal of help from others - see the "README" for a complete list. SEE ALSO
Imager(3), Imager::Color. http://imager.perl.org/ perl v5.14.2 2011-06-06 Imager::Color::Float(3pm)
All times are GMT -4. The time now is 03:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy