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
mhmail(1)						      General Commands Manual							 mhmail(1)

NAME
mhmail - send or read mail (only available within the message handling system, mh) SYNOPSIS
mhmail [addrs...] [options] OPTIONS
Specifies the text of the message. If it is specified, then the standard input is not read. Specifies addresses to be placed in the cc: field of the message. Specifies the content of the From: header of the draft. The address given is placed in the From: field of the mes- sage. The Sender: field is filled in correctly by post. Prints a list of the valid options for this command. Specifies the mail system over which mail is sent. The only value allowed is smtp, which is the standard mail system. Additional values are supported only for use with other mail systems. Provides the text of the Subject: field of the message. DESCRIPTION
The mhmail program is intended as a replacement for the standard mail programs, bellmail and ucbmail. See binmail(1) and mail(1) for more details of these mail programs. When invoked without arguments, it simply invokes inc to incorporate new messages from the user's maildrop. When one or more users is specified, a message is read from the standard input and spooled to a temporary file. The mhmail program then invokes post with the name of the temporary file as its argument to deliver the message to the specified user. Normally, people will use comp and send to send messages. RESTRICTIONS
Messages with a null body part will not be sent by mhmail. You must include some body text in all messages to be sent by mhmail. For this version, the -mts option only supports the value smtp. Additional values are supported for use only with other mail systems. FILES
Program to incorporate a maildrop into a folder. Program to deliver a message. Temporary copy of message. SEE ALSO
inc(1), post(8) mhmail(1)
All times are GMT -4. The time now is 06:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy