- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Adding color to shell output results
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2011 12:55 PM
09-15-2011 12:55 PM
Adding color to shell output results
In other OS's (Linux and Sun) i can write a shell - listed below - and the results will display back in color. i am not able to get this to work in HPUX. Am i missing something??
# Global options
COLORALL0="\033[0;1;30m### COLORALL0 ### \033[0;0m"
COLORALL1="\033[0;1;31m### COLORALL1 ### \033[0;0m"
COLORALL2="\033[0;1;32m### COLORALL2 ### \033[0;0m"
COLORALL3="\033[0;1;33m### COLORALL3 ### \033[0;0m"
COLORALL4="\033[0;1;34m### COLORALL4 ### \033[0;0m"
COLORALL5="\033[0;1;35m### COLORALL5 ### \033[0;0m"
COLORALL6="\033[0;1;36m### COLORALL6 ### \033[0;0m"
COLORALL7="\033[0;1;37m### COLORALL7 ### \033[0;0m"
COLORALL8="\033[0;1;38m### COLORALL8 ### \033[0;0m"
COLORALL9="\033[0;1;39m### COLORALL9 ### \033[0;0m"
NUM=9
until [[ $NUM = 0 ]]
do
eval echo "\$COLORALL$NUM"
NUM=`expr ${NUM} - 1`
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2011 03:39 PM
09-15-2011 03:39 PM
Re: Adding color to shell output results
Hi:
First, your terminal type must support color. Then, it is safest to use 'tput'. Have a look at the 'tput()' manpages.
See Bill Hassell's post, here, for more insight:
Regards!
...JRF...
- Tags:
- tput
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2011 12:29 PM
09-16-2011 12:29 PM
Re: Adding color to shell output results
To expand a bit on colors, James is correct -- the shell knows nothing about colors. And historically, real terminals (tm) have only two colors (black and white, possibly black and green or orange). Colors are typically associated with graphics and in the word of Unixes, the PC or Xwindow device brought the possibility of colors for text. As mentioned in the link above, there are some 1800 terminal manufacturer and models that have an entry in the terminfo (man terminfo) database on HP-UX. But it's a Tower of Babel -- Wyse is incompatible with Tektronix which is incompatible with Dec which is incompatible with HP, etc. So you first establish what kind of terminal you have. PuTTY is an emulator (imitator) of the classic DEC VT100, but a vt100 has no color except black and white. Yet PuTTY allows you to change the font and background color and (not keeping with a proper emulator) adds ANSI color escape codes. Then there are PC products like SecureCRT, Reflection/Attachmate, Minisoft, QCTerm, etc which have other emulation capabilities. To make things really fun, Linux is typically run in Xwindows so the emulator can be xterm. But when the Linux box telnets into the HP-UX system, the TERM value preset from Linux is "linux" which is not a terminal at all.
So there is no standard -- or better yet, there so many to choose from that there is no single answer. When the emulator and display hardware are constrained, then there can be a solution but you'll need to see what is required for your emulator, then provide appropriate aliases. Note that you may have to consider other users accessing the system which do not share the same hardware and emulator. That's why the command: ttytype(1) is so useful in .profile
Bill Hassell, sysadmin