Linux - Colorizing Text in Files - linux

I'm on CentOS 6, and I'm playing around with the Pre-Login file message, located here:
# vi /etc/issue
I want to add some custom text of mine, and colorizing that text.
Here's my file text for now:
----------------------------
Welcome to my Testing Server
----------------------------
I've used an example from a friend of mine, on his CentOS 5:
----------------------------
^[[47;31m Welcome to my Testing Server ^[[0m
----------------------------
I see it working fine on his box, as I ssh to it.
But I copied and pasted it into my /etc/issue file and it returns everything as text.
Am I missing something?

The ^[ is not a literal carat followed by a bracket, it is a control character. When copying from your friend's box to yours, the control characters have been taken literally and cease to work properly, see this for more information on colorizing /etc/issue

Related

How to disable encoding in a text-editor?

This is such a basic question I am surprised I could not easily find an answer to it:
I use Notepad++ to write my scripts in. Someone sent me some code for a shell script (.sh) that I could modify to suit my needs. I simply changed a small bit of text using Notepad++ (on Windows) and used FileZilla (SFTP) to upload it to my server (Debian Linux).
There were a few problems with this that it took my server admin an hour to find, namely:
FileZilla, for whatever reason, defaults to ASCII rather than binary! (changed it to binary and removed the .sh association with ASCII)
The permissions were wrong, chmod took care of this
Problem is it STILL did not work. To fix it my server admin simply copied the text right on the server (using vim or nano) into a new shell script file and saved that. Before he kept saying the problem was Windows (which he loves to hate on) but it seems it is the encoding that text-editors are using that is corrupting the files.
He said my text-editor encoding needs to be said to "None". However, that is not an option - only ANSI, UTF and UTS variants are options!
How can I create a shell script on Windows with no encoding whatsoever so that it doesn't get corrupted?
I need to be able to simply transfer the file to the server, I can't mess around with modifying it once on the server which is wholly impractical.
To fix it EndOfLine and encoding on Notepad++ :
On the bottom right of Notepad++ you can right click on the left of the encoding "UTF-8" and click on Convert UNIX(LF) format. Be sure to change encoding to UTF-8 if it is not the case.
In Filezilla :
Transfert mode : auto

Linux Send Mail - Command Line

I have a little script on Centos 6.5 64 bit which sends email content of a text file (as inline and NOT as attachment) to a user:
mail -s "Zabbix Alerts" -r sender#mydomain.com receiver#mydomain.com < /filename
It used to work great for a long time. Today we have got a new server Centos 6.7 64bit and the same scripts sends what is expected but not as inline but as attachment.
We need the content of the text file as inline text (not attachment).
I have already spent a few hours find the cause but no luck.
I will be really thankful if someone can help me.
I just found it is some problem with the text file. When I open it in vi it shows too many ^M characters. When I remove that it becomes fine. So it is not a problem with mail but the file

How to display UTF characters in message line of gVim?

I am using a German version of gVim 7.4 on Windows 7.
The message line does not display UTF-8 characters correctly.
For example, it shows
Wort zu ~/vimfiles/spell/de.utf-8.add hinzugef<fc>gt
instead of
Wort zu ~/vimfiles/spell/de.utf-8.add hinzugefĆ¼gt
after having added a word to the spelling directory.
How can I make it display the umlaut?
Problem related to the charset converter for gvim on windows,
From help :usr_45, it says:
Using different languages only works when Vim was compiled to handle
it. To find out if it works, use the ":version" command and check the
output for "+gettext" and "+multi_lang". If they are there, you are
OK. If you see "-gettext" or "-multi_lang" you will have to find
another Vim.
If there is
"-gettext" or "-multi_lange", or "-iconv", you need to download proper library your own
for windows, see this post https://superuser.com/questions/207264/gvim-utf-8-in-windows for
more information and downlinks for the library on windows

perl5 Number Sign # not working for comments

I have a very strange problem..
perl5 Number Sign # not working correctly for comments..
We use emperl, mod_perl, apache, linux..
In some programs if I have a line commented out with a number sign # or just a number sign # by itself on a line, all of the code below that line doesn't work correctly.
There is a sysadmin so I don't have access or control over any of the settings on the server.
This is a new issue everything always worked previously.
So many possible area's that this might be coming from that I'm checking to see if anybody has run across this..
Any suggestions?
Found the issue:
Was transferring the files from LINUX to Windows to edit them.
If the file was originally created in Windows the end of a line was just a <CR> and for some reason the whole file wasn't running right. It mainly showed up when using the hash symbol for perl comments.
When I made sure the files had end of lines with <CR><LF>, this solved this issue.

Adding Security Message to RHEL 5 Login Screen

What are the steps to configure the login screen of Red Hat Enterprise Linux 5 to display a large paragraph of text?
Background Information: The text is a security warning required by the company I work for to be presented to all users prior to them logging in. They must be able to read the text prior to logging in.
We are using GDM and it does not read /etc/issue by default. I have placed a copy of the text under the [greeter] section in /etc/gdm/custom.conf. The issue is that the text is displayed on one line and runs off the screen.
Is there a way to present the whole paragraph in plain text without having to resort to using a rendered background image of the text such as how this DOE employee did?
Example of using image: http://cc.jlab.org/docs/security/banners/linux-graphical-banner.html
Place the text in a file, and point InfoMsgFile to the file.
[greater]
InfoMsgFile=/etc/motd

Resources