How to print color text in AIX?


 
Thread Tools Search this Thread
Operating Systems AIX How to print color text in AIX?
# 1  
Old 07-22-2015
How to print color text in AIX?

Hi
I'd like to print color text and I've tried this:
Code:
echo "\033[0;31mHI\033[m"

but it didn't woked. When I changed 0 --> 1/4/5, the text "HI" --> bold/underline/blink, but when I changed 31 or 33 to other values, the color didn't change.

What's the problem. Need to install something ???
# 2  
Old 07-22-2015
Hello bobochacha,

I don't have AIX box with me but could you please try as follows and let me know if this helps.
Code:
 echo -e "\033[0;31mHI\033[m"

We need to add -e option with echo as it will enable interpretation of backslash escapes.


Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 07-22-2015
Why don't you use printf which behaves consistently across systems (which echo does not do reliably)?
This User Gave Thanks to RudiC For This Post:
# 4  
Old 07-22-2015
Quote:
Originally Posted by RavinderSingh13
Hello bobochacha,

I don't have AIX box with me but could you please try as follows and let me know if this helps.
Code:
 echo -e "\033[0;31mHI\033[m"

We need to add -e option with echo as it will enable interpretation of backslash escapes.


Thanks,
R. Singh
Wrong answer. It's AIX, not Linux.

---------- Post updated at 01:12 PM ---------- Previous update was at 01:08 PM ----------

Quote:
Originally Posted by bobochacha29
Hi
I'd like to print color text and I've tried this:
Code:
echo "\033[0;31mHI\033[m"

but it didn't woked. When I changed 0 --> 1/4/5, the text "HI" --> bold/underline/blink, but when I changed 31 or 33 to other values, the color didn't change.

What's the problem. Need to install something ???
The problem is your terminal. What you want to do, works well on any ANSI-capable terminal. E.g. in my xterm it works. But if you have some dumb terminal, or dtterm (I think - didn't check) this ANSI sequence will not work. If you want to use portable sequences, you have to consult termcap database, what it can provide to you, using infocmp and you can use tput command to make text bold, underline and so on.
This User Gave Thanks to agent.kgb For This Post:
# 5  
Old 07-23-2015
Quote:
Originally Posted by RavinderSingh13
Hello bobochacha,

I don't have AIX box with me but could you please try as follows and let me know if this helps.
Code:
 echo -e "\033[0;31mHI\033[m"

We need to add -e option with echo as it will enable interpretation of backslash escapes.


Thanks,
R. Singh
Quote:
Originally Posted by RudiC
Why don't you use printf which behaves consistently across systems (which echo does not do reliably)?
Thank for your helps. but nothing worked SmilieSmilieSmilie

Quote:
Originally Posted by agent.kgb


The problem is your terminal. What you want to do, works well on any ANSI-capable terminal. E.g. in my xterm it works. But if you have some dumb terminal, or dtterm (I think - didn't check) this ANSI sequence will not work. If you want to use portable sequences, you have to consult termcap database, what it can provide to you, using infocmp and you can use tput command to make text bold, underline and so on.
Yeah, I tried using mobaxterm and it worked SmilieSmilieSmilie. It seems that securecrt doesn't support this.

Found "xterm" in securecrt, now it's OK. Thanks guy SmilieSmilieSmilie

Last edited by bobochacha29; 07-23-2015 at 01:03 AM..
# 6  
Old 07-25-2015
Hi Bobochacha,

can you please tell me how did you solve this issue with mobaxterm? I have also installed mobaxterm but I dont know how to change the colours of the terminal.

Br,
Neha
# 7  
Old 07-26-2015
Quote:
Originally Posted by NehaJi
Hi Bobochacha,

can you please tell me how did you solve this issue with mobaxterm? I have also installed mobaxterm but I dont know how to change the colours of the terminal.

Br,
Neha
I didn't do anything with mobaxterm, just installed and used.
In securecrt, I changed terminal from vt100 --> xterm ( Option / Session Option / Emulation ) and enable the ANSI color option

Hope it helps
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

color print using perl

Hi i want to print the text in different color using perl script. i am able to print on console(terminal). but if i try to print the same into a file, i am not able to do color.pl #!/bin/usr/perl use Term::ANSIColor; print "This text is normal.\n"; use Term::ANSIColor qw(:constants);... (3 Replies)
Discussion started by: roopa
3 Replies

2. Programming

changing text color in c

I'm writing my own Unix ls command in c and I was wondering if anyone knows how to or can point me to a tutorial that shows me how to change the text color of the filename depending on if it's a directory, regular file, linked file, etc..., like the real ls command does? Thanks. (4 Replies)
Discussion started by: snag49ers
4 Replies

3. Red Hat

New Background and Text Color

Hi. How do I change the background color and text in Fedora. I did find the set_color -b command. Thanks (1 Reply)
Discussion started by: Ccccc
1 Replies

4. Shell Programming and Scripting

text color

Hi all I have a file contains columns showing figures as below : Input file A B C D 50 60 90 E 100 20 53 F 30 40 70 G 25 27 45 I want to color the value above or equal 90 by red and to be shown as below output file... (5 Replies)
Discussion started by: Bluetoot
5 Replies

5. AIX

ls color on AIX

Hi, I have retrieved the following rpm coreutils-5.2.1-2.aix5.1.ppc.rpm to get color with ls command. It doesnt work very well with | more. ls -ltr | more ^[[0mtotal 8 -rwxr--r-- 1 ora10 dba 4362 2009-01-08 11:08 ^[[01;32mora_base.ksh^[[0m ^[[m It works fine with pg ls -ltr | pg... (3 Replies)
Discussion started by: tagger
3 Replies

6. UNIX for Dummies Questions & Answers

Print in color

I have a short code below: awk 'NR==1 {printf "'$information'-MYDATA-'$information' \n"} {print $0}' data.file > newdata.file I want the "information" color in RED and MYDATA in BLUE. How can I do it? Please help!!!! (3 Replies)
Discussion started by: bobo
3 Replies

7. AIX

Configuring Color Laser ptr in AIX

Hi All, I have Network color laser printer which is to be configured in AIX5L. The Model of the printer is OKI C3200. Will it is supported with AIX 5..? I could not find any drivers for this. Will any compatible drivers are available for this printer... I tried with the default drivers hplj-4... (2 Replies)
Discussion started by: helloajith
2 Replies
Login or Register to Ask a Question