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
SSH-ARGV0(1)						    BSD General Commands Manual 					      SSH-ARGV0(1)

NAME
ssh-argv0 -- replaces the old ssh command-name as hostname handling SYNOPSIS
hostname | user@hostname [-l login_name] [command] hostname | user@hostname [-afgknqstvxACNTX1246] [-b bind_address] [-c cipher_spec] [-e escape_char] [-i identity_file] [-l login_name] [-m mac_spec] [-o option] [-p port] [-F configfile] [-L port:host:hostport] [-R port:host:hostport] [-D port] [command] DESCRIPTION
ssh-argv0 replaces the old ssh command-name as hostname handling. If you link to this script with a hostname then executing the link is equivalent to having executed ssh with that hostname as an argument. All other arguments are passed to ssh and will be processed normally. OPTIONS
See ssh(1). FILES
See ssh(1). AUTHORS
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. Jonathan Amery wrote this ssh-argv0 script and the associated documentation. SEE ALSO
ssh(1) Debian Project September 7, 2001 Debian Project
All times are GMT -4. The time now is 01:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy