Assign specific Color to the outputs in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Assign specific Color to the outputs in script
# 1  
Old 05-18-2012
Error Assign specific Color to the outputs in script

Hi,

Im programming an interactive menu that verifies the exports of my oracle DB, and im having some trouble finding a process that outputs for example a green command line when the export terminated successfully. i have something like this

Code:
cat /variosnew/fullexports/IMAGES/full_imp_images.log | grep succesfully

What i want is, if the return is successfully then output it in green... if not red
SmilieSmilieSmilie
Maybe with:

Code:
echo $?

SmilieSmilie
Thanks for your help!!
# 2  
Old 05-18-2012
That's a useless use of cat.

What exactly do you want to be colored green?
# 3  
Old 05-18-2012
That cat command return "Export terminated successfully Without Warnings" that i want in green
# 4  
Old 05-18-2012
The cat does nothing, the cat is completely useless there and can be thrown away. It's grep that does all the work.

Code:
LINE=`grep successfully /variosnew/fullexports/IMAGES/full_imp_images.log`

if [ $? -eq 0 ]
then
        printf "\033[01;32m%s\033[00m\n" "$LINE"
else
        printf "\033[01;31m%s\033[00m\n" "'successfully' not found in log"
fi

This User Gave Thanks to Corona688 For This Post:
# 5  
Old 05-20-2012
will try it and post you back how ir goes. in advance, thanks for your help.
# 6  
Old 05-20-2012
If you are using Linux, you can
Code:
grep --color successfully /variosnew/fullexports/IMAGES/full_imp_images.log

For more colors, pls refer to Chi Hung Chan: Give Your Shell Some Colours
This User Gave Thanks to chihung For This Post:
# 7  
Old 05-21-2012
It works perfectly.... Thanks a lot!!!

---------- Post updated at 09:21 AM ---------- Previous update was at 09:20 AM ----------

Im using AIX.. But will save your commento for future references. Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to assign points to variables based on conditions and update specific field

I have been reading old posts and trying to come up with a solution for the below: Use a tab-delimited input file to assign point to variables that are used to update a specific field, Rank. I really couldn't find too much in the way of assigning points to variable, but made an attempt at an awk... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Solaris

Sol 10 PAM config - how to assign modules to specific users

Hi, was after some help for the following. I want to enforce local passwd authentication for service accounts and kerberos authentication for users. Solaris 11 lets me assign different PAM modules to specific users via usermod and linux lets me define via UID, but I can't find a way to do this... (0 Replies)
Discussion started by: melias
0 Replies

3. Shell Programming and Scripting

Regex in sed to find specific pattern and assign to variable

(5 Replies)
Discussion started by: radioactive9
5 Replies

4. Shell Programming and Scripting

awk assign output of array to specific field-number

With this script i want to print the output to a specific field-number . Can anybody help? awk 'NR=FNR{split(FILENAME,fn,"_");nr=$2;f = $1} END{for (i=1;i<=f;i++) print i,$fn=nr}' input_5.csv input_6.csvinput_5.csv 4 135 5 185 6 85 11 30input_6.csv 1 90 3 58 4 135 7 60 8 55 10... (1 Reply)
Discussion started by: sdf
1 Replies

5. Shell Programming and Scripting

create outputs from other command outputs

hi friends, The code: i=1 while do filename=`/usr/bin/ls -l| awk '{ print $9}'` echo $filename>>summary.csv #Gives the name of the file stored at column 9 count=`wc -l $filename | awk '{print $1}'` echo $count>>summary.csv #Gives just the count of lines of file "filename" i=`expr... (1 Reply)
Discussion started by: rajsharma
1 Replies

6. UNIX for Dummies Questions & Answers

Using SED to change a specific word's color?

Ok so all i'm trying to do here is output a file and change the color of a specific word. I can't use grep with color because I need all lines of the file not just lines that match the pattern. I can get this substitution to work but when it displays it shows exactly what i'm putting it rather... (14 Replies)
Discussion started by: MrEddy
14 Replies

7. Shell Programming and Scripting

Script that takes in variables, and outputs to another text or script file

Ok, I sort of need to create a command files that will be ftped to another server to run. I have some input variable that will need to be read, and then transformed into another script file. Here are some examples. Server 1: outputCmd.sh passing in ./outputCmd.sh nh8oaxt Release_4_0... (1 Reply)
Discussion started by: orozcom
1 Replies

8. Shell Programming and Scripting

How to assign the specific value

Hi Everyone, How to assign the specific value which return from database? here is the return value from database --> (return status = 0) 0 <----- this I only need to get the "0" .. assign to another declare variable. hope someone will help me.. Please thank you.. (4 Replies)
Discussion started by: ryanW
4 Replies
Login or Register to Ask a Question