The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
List Process with their Status. varungupta UNIX for Advanced & Expert Users 2 03-21-2008 09:27 PM
Ftp Service /process Status GaneshB Linux 1 03-10-2008 10:15 AM
Process Status Without Shared Memory altinkaya SUN Solaris 1 02-27-2008 08:26 AM
Getting status of a signal in process? bluehive UNIX for Advanced & Expert Users 2 01-18-2008 03:56 AM
Process status display Frank2004 AIX 2 06-01-2005 06:18 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2008
draco draco is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 38
Colloring Status of process or package

Hi there all again,

I am building a menu script for viewing packages and deamons and printers and all..

I know how to collor text to red or green.
But I get my results from status and put it in a array.
How can I change a result that is standing in a array to build collor around it.
For example

STATE_XCFA[1] can be UP or DOWN
If it is UP I want it to be green and if it is DOWN i want it to be red.




Example so you see where I'm getting at.
Echo "STATUS: ${STATE_XCFA[1]} | STATE: ${STATE_XCFA[2]} | NODE: ${STATE_XCFA[4]}|\n"

Should show as follow

STATUS: UP | STATE: RUNNING | NODE: HPUX006

Or

STATUS: DOWN | STATE: RESTARTING | NODE: HPUX005

Thanx people!
  #2 (permalink)  
Old 10-10-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,311

Code:
case ${STATE_XCFA[1]} in
     UP) clr=32 ;;
     DOWN) clr=31 ;;
     *) clr=0;
esac
printf "STATUS: \e[${clr}m%s\e[0m | STATE: \e[${clr}m%s\e[0m | NODE: \e[${clr}m%s\e[0m|\n" \
       "${STATE_XCFA[1]}" "${STATE_XCFA[2]}" "${STATE_XCFA[4]}"
  #3 (permalink)  
Old 10-10-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,382
which shell are you using?? because what mr.johnson suggested might not work in all shell
  #4 (permalink)  
Old 10-10-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,311
Quote:
Originally Posted by vidyadhar85 View Post
which shell are you using?? because what mr.johnson suggested might not work in all shell

My suggestion will work in all Bourne-type shells.

It will not work in some non-standard terminals.
  #5 (permalink)  
Old 10-13-2008
draco draco is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 38
I'm using Korn
  #6 (permalink)  
Old 10-13-2008
draco draco is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 38
This goes together with my other question actually.
Menu help with array selection
So ummmm how do I set this up how you explain it?
I am using korn
I'm on a HP UX System
  #7 (permalink)  
Old 10-13-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,311
Quote:
Originally Posted by draco View Post
This goes together with my other question actually.
Menu help with array selection
So ummmm how do I set this up how you explain it?

Put the code I gave you into your script. Adjust it as necessary to conform to your use.
Quote:
I am using korn

The Korn shell is a Bourne-type shell.
Quote:
I'm on a HP UX System
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0