- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: write with color
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
Forums
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
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
06-06-2003 11:16 AM
06-06-2003 11:16 AM
write with color
How can i write in the terminal (xterm)
with colors.
I write a script that read a file and it
must write some lines with color.
How can i do it?
I use HPUX 11.0, i can write sh, perl, c
no metter just to get the efect.
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 11:21 AM
06-06-2003 11:21 AM
Re: write with color
There are Perl modules, C libraries, and C++ libraries for this.
I'd recommend you get a book though, it's tricky at best.
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 11:29 AM
06-06-2003 11:29 AM
Re: write with color
The best I can tell you is how to highlight a string of text.
at the beginning of your script put these two lines:
BOLD="`tput smso`"
NORMAL="`tput rmso`"
Then to make something bold (highlighted) do it like this:
echo "${BOLD}bla bla bla${NORMAL}"
and "bla bla bla" will be highlighted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 11:43 AM
06-06-2003 11:43 AM
Re: write with color
I think that the best you can do is bold or blink. Check this out:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xec0e36e69499d611abdb0090277a778c,00.html
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2003 02:46 PM
06-06-2003 02:46 PM
Re: write with color
The tput command can generate a terminal-specific escape sequence for any of the features listed for the terminfo database entry of that terminal. To see what is defined for the current terminal:
untic $TERM
In all cases, $TERM must match the terminal you are using. If your profile sets $TERM using ttytype, then the untic command will show the features available for that terminal. Decode the untic entries using the man page for terminfo (which defines the curses library calls).
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 09:08 AM
06-13-2003 09:08 AM
Re: write with color
Caesar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 09:49 AM
06-13-2003 09:49 AM
Re: write with color
# sets parameters for highlighting or colorizing text
bold="$(tput smso 2>/dev/null)"
undl="$(tput smul 2>/dev/null)"
norm="$(tput rmso 2>/dev/null)"
bla="$(tput setaf 0 2>/dev/null)"
red="$(tput setaf 1 2>/dev/null)"
gre="$(tput setaf 2 2>/dev/null)"
yel="$(tput setaf 3 2>/dev/null)"
blu="$(tput setaf 4 2>/dev/null)"
pur="$(tput setaf 5 2>/dev/null)"
cya="$(tput setaf 6 2>/dev/null)"
whi="$(tput setaf 7 2>/dev/null)"
off="$(tput sgr0 2>/dev/null)"
HI="$(tput smso 2>/dev/null)"
LO="$(tput sgr0 2>/dev/null)"
but as bill pointed out, these are terminal specific esacape sequences. and xterm doesn't have any. these will work for a dtterm. you'll have to test what capabilities the terminal has and set values appropriately. such as for an xterm you could use bold for yellow and bold inverse for red and underline for blue, etc. This way if someone is using an xterm there is some differentiation in the visual presentation albeit not colors. and if someone is using an dtterm their visual presentation would be differentiated by colors.