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-COPY-ID(1)						      General Commands Manual						    SSH-COPY-ID(1)

NAME
ssh-copy-id - install your public key in a remote machine's authorized_keys SYNOPSIS
ssh-copy-id [-i [identity_file]] [user@]machine DESCRIPTION
ssh-copy-id is a script that uses ssh to log into a remote machine and append the indicated identity file to that machine's ~/.ssh/autho- rized_keys file. If the -i option is given then the identity file (defaults to ~/.ssh/id_rsa.pub) is used, regardless of whether there are any keys in your ssh-agent. Otherwise, if this: ssh-add -L provides any output, it uses that in preference to the identity file. If the -i option is used, or the ssh-add produced no output, then it uses the contents of the identity file. Once it has one or more fin- gerprints (by whatever means) it uses ssh to append them to ~/.ssh/authorized_keys on the remote machine (creating the file, and directory, if necessary.) NOTES
This program does not modify the permissions of any pre-existing files or directories. Therefore, if the remote sshd has StrictModes set in its configuration, then the user's home, ~/.ssh folder, and ~/.ssh/authorized_keys file may need to have group writability disabled manu- ally, e.g. via chmod go-w ~ ~/.ssh ~/.ssh/authorized_keys on the remote machine. SEE ALSO
ssh(1), ssh-agent(1), sshd(8) OpenSSH 14 November 1999 SSH-COPY-ID(1)
All times are GMT -4. The time now is 06:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy