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
# 8  
Old 05-24-2012
Hi... me again... i find out soumething today... when you say

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

you are including "unsuccessfully" like a green... and it shouldnt... help please...

---------- Post updated at 09:27 AM ---------- Previous update was at 09:26 AM ----------

is there something like a "distinct" command????
# 9  
Old 05-24-2012
Quote:
Originally Posted by blacksteel1988
Hi... me again... i find out soumething today... when you say

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

you are including "unsuccessfully" like a green... and it shouldnt... help please...
Please show a sample from your logfile so I can tell how to match it more specifically. If successfully appears at the beginning of a line, you could grep "^successfully" for instance.
Quote:
is there something like a "distinct" command?
If I get your meaning, i.e. 'distinct' like in SQL, people often use sort -u for that, but I suspect there are dates and the like which make the entries differ from each other even when you'd like them to be combined. Things like cut and/or awk can trim it down to the parts you want, after which you can sort -u to remove the duplicates. Depending on the problem, sometimes people do it all in one awk, noting down the things to keep in an associative array until the program ends, when they're all printed without duplicates. The output from this tends to be in unpredictable and arbitrary order however.

Show the input you have and the output you want.
# 10  
Old 05-24-2012
logfile example

. exporting snapshots
. exporting snapshot logs
. exporting job queues
. exporting refresh groups and children
. exporting dimensions
. exporting post-schema procedural objects and actions
. exporting user history table
. exporting default and system auditing options
. exporting statistics
Export terminated successfully without warnings.
# 11  
Old 05-24-2012
Grep for 'terminated successfully', then.

I still need to see the input you have and output you want for this 'distinct' problem.
# 12  
Old 05-24-2012
i really don want to remove duplicates, cause there aint no duplicates... my problem now is that whenever the export terminate successfully or unsuccesfully it recognizes it like a successfull command and it displays the messages in green. I tried
Code:
grep -w 'successfully' /variosnew/fullexports/IMAGES/full_imp_images.log

and it seems to work...

but i want to know your comments about this. And thanks for taking your time.

Greetings!!

---------- Post updated at 10:06 AM ---------- Previous update was at 10:04 AM ----------

the output for the 'distinct' would be a warning llike ' please contact your systema administrator or dba'
# 13  
Old 05-24-2012
Quote:
Originally Posted by blacksteel1988
i really don want to remove duplicates, cause there aint no duplicates... my problem now is that whenever the export terminate successfully or unsuccesfully it recognizes it like a successfull command and it displays the messages in green. I tried
Code:
grep -w 'successfully' /variosnew/fullexports/IMAGES/full_imp_images.log

and it seems to work...

but i want to know your comments about this. And thanks for taking your time.
In general this seems like a good way to detect success here, since there's only one way for it to be successful -- anything other than 'terminated successfully' will be considered an error. As long as you know there isn't going to be more than one thing in the file, this should work.

If there could be a successful run followed by a failed one, it will find the successful run and print success falsely.
Quote:
the output for the 'distinct' would be a warning llike ' please contact your systema administrator or dba'
Yes, but why would it be printing that? Smilie If you don't mean 'distinct' in the SQL sense, what do you mean it in? What's distinct, about what?

You're going to have to show the input you have, the output you want, and the logic which explains why one causes the other if you want to be understood without playing a game of 20-questions.
# 14  
Old 05-24-2012
Ok, i need that i.e. the export did not was execute successfully displays any other message of warning. Why? because it has to be reported to the dba's or system admins for a fast solution since the export could fail for more than one reason. If the export terminated successfully i need to print the message "export terminated successfully".. with that i have no problem... now, the thing is, when i mean "distinct", its an example, i mean different to successfull, because i found out today that the grep command finds the successfull and the unsuccessfull line equals.. thats why i need to print a different message when it goes unsuccesfull. But with the grep for 'Terminated successfully' i believe i have my alternative. Thats my way of see it. Then again this is part of my input and output:

LINE=`grep 'terminated successfully' /variosnew/fullexports/IMAGES/full_imp_imagenes.log`

Code:
if [ $? -eq 0 ]
then
        printf "\033[01;32m%s\033[00m\n" "$LINE2"
else
        printf "\033[01;31m%s\033[00m\n" "And error was found, please contact your dba or sysadm"
fi
ls -trl /variosnew/fullexports/IMAGES/;
sleep 5
;;

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