Change text color in Korn shell to highlight Error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change text color in Korn shell to highlight Error
# 1  
Old 11-05-2012
Code Change text color in Korn shell to highlight Error

Hi this is my first post, so forgive me if what I'm requesting doesn't make sense.

I'm connecting into a Unix server via SSH and using a Korn Shell (#!/bin/ksh). The Unix server has Oracle 11g installed on it and there are a number of scripts already setup to query the Oracle database to perform specific functions (ex: reset a user's password, etc.).

When running these scripts the output shows more information then I want to see (ex: information about the oracle database connection). I want only specific text in the output to be colored (ex: successful text = green, error text = red).

Example 1:
Code:
Database connection text...
ERROR: The command you specified is invalid.
More database text...


Example 2:

Code:
Database connection text...
SUCCESS: The command completed successfully.
More database text...

The one problem is I don't have access to edit these scripts, so I was looking at adding some custom code into the /etc/bashrc or /etc/profile file to accomplish this. Is this possible? I have been playing with adding code in the /etc/profile to change the prompt colors, but not sure how to change the color of specific text from a scripts output. Also I can look at the code inside the script, which starts out like this ($ORACLE_HOME/bin/sqlplus maint/). Any insight into how I could do this is appreciated.
# 2  
Old 11-05-2012
This thread might help.
# 3  
Old 11-05-2012
Try filtering your log files through e.g. awk:
Code:
 awk '/SUCCESS/ {$0="\033[32;1m"$0"\033[0m"} /ERROR/ {$0="\033[31;1m"$0"\033[0m"} 1'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Change text color from echo command?

I have a bash script that starts and stops a game among other things through in.fifo and out.fifo In game the text comes out gray . Kinda hard to see in game window . I would like to change it to purple and maybe capitalize it. #!/bin/bash #nwservctl.sh cd... (5 Replies)
Discussion started by: 222222quick
5 Replies

2. UNIX for Dummies Questions & Answers

Highlight text in shell o/p

Hi All, Can anyone tell me how to highlight a particular text in shell output or formattting a text in shell ? (1 Reply)
Discussion started by: prasanna2166
1 Replies

3. Shell Programming and Scripting

Color text on shell programming

hello i need the main reference for color code on shell programing i know a few color like: RED='\033 (2 Replies)
Discussion started by: nimafire
2 Replies

4. Shell Programming and Scripting

How to change the color inside email using shell script?

hi, i want to send an email from unix using mailx command. mailx -s "subject" "email@abc.com" < email.txt Email.txt contains some file names that are transferred successfully and some that failed. so the files that got failed to tranfer, should be displayed in red color in the mail. is it... (1 Reply)
Discussion started by: Little
1 Replies

5. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies

6. Shell Programming and Scripting

change text color in postscript file

Hi everyone, I have a program that produces postscript files on the fly The color of the files produced are in black and white I want to change the text color of postscript file as the file is being produced without having to manually go into the ps file and change it myself. Any Ideas?... (5 Replies)
Discussion started by: walforum
5 Replies

7. Shell Programming and Scripting

How to: Parse text string into variables using Korn shell

I am writing a script to keep check on free disk space, and I would like to find a way to parse $LINE (see code below) into a numeric value (for free disk space percentage) and a string value (for mount point). If possible, I would like to avoid sed or any additional use of awk since I am not very... (7 Replies)
Discussion started by: shew01
7 Replies

8. UNIX for Dummies Questions & Answers

How to change the font or color of text

Hi Gurus, I have a small requirement where i want to change the color & font of some text in a file. i have a file error.txt which will be created in the script using egrep. After that iam adding these lines at head & tail to that file using the following code awk 'BEGIN{print"Please... (4 Replies)
Discussion started by: pssandeep
4 Replies

9. Linux

Korn Shell Script to change the permissions

Hi, All I am trying to change the permission for all the files in the current dir such that the user(owner) have the read write and excute permissions. When I excute the korn shell it will change the whole files and directory permissions as "rwx". Any help will be highly appreciated. Thanks (1 Reply)
Discussion started by: uhelp
1 Replies

10. UNIX for Dummies Questions & Answers

Changing korn shell script text Menu colors?

Is it possible to change the color of text in a korn shell script Menu? I can change the color of session text through my telnet client but I want to be able to change color text in the Korn shell menu to highlight certain items. (6 Replies)
Discussion started by: darthur
6 Replies
Login or Register to Ask a Question