Need help on unix scripting. I am at hello world level. Your help would be greatly appreciated.
Need to automate the following steps (OS--> AIX )
1. cd /advx/R8.1MR2/TOP/logs ( I navigate to this directory)
2. Monitor the current date ULOG for specific error pattern
Code:
=> ls -lrt ULOG.08*
-rw-rw-rw- 1 vssrt vssgrp 24370 Aug 01 23:57 ULOG.080112
-rw-rw-rw- 1 vssrt vssgrp 26094 Aug 02 23:59 ULOG.080212
-rw-rw-rw- 1 vssrt vssgrp 76357 Aug 03 23:46 ULOG.080312
-rw-rw-rw- 1 vssrt vssgrp 21232 Aug 04 23:47 ULOG.080412
-rw-rw-rw- 1 vssrt vssgrp 18235 Aug 05 23:49 ULOG.080512
-rw-rw-rw- 1 vssrt vssgrp 45460 Aug 06 23:51 ULOG.080612
-rw-rw-rw- 1 vssrt vssgrp 24888 Aug 07 23:52 ULOG.080712
-rw-rw-rw- 1 vssrt vssgrp 23013 Aug 08 23:54 ULOG.080812
-rw-rw-rw- 1 vssrt vssgrp 25403 Aug 09 23:56 ULOG.080912
-rw-rw-rw- 1 vssrt vssgrp 24354 Aug 10 23:58 ULOG.081012
-rw-rw-rw- 1 vssrt vssgrp 18289 Aug 11 23:59 ULOG.081112
-rw-rw-rw- 1 vssrt vssgrp 18160 Aug 12 23:46 ULOG.081212
-rw-rw-rw- 1 vssrt vssgrp 22486 Aug 13 23:47 ULOG.081312
-rw-rw-rw- 1 vssrt vssgrp 22656 Aug 14 23:49 ULOG.081412
-rw-rw-rw- 1 vssrt vssgrp 50666 Aug 15 23:51 ULOG.081512
-rw-rw-rw- 1 vssrt vssgrp 6548 Aug 16 07:06 ULOG.081612
=> grep -ice "Invalid Transaction" ULOG.081612
0
Requirement is if it returns not equal to 0 or greater than 0 then mail the result to specific members.
Moderator's Comments:
Please use code tags next time for your code and data.
Last edited by zaxxon; 08-16-2012 at 09:24 AM..
Reason: code tags
cd /advx/edgrt/R8.0g/TOP/logs
if grep -i "Invalid Transaction" ULOG.$(date +%m%d%y) >errors_today 2>/dev/null
then
mail "someone@somehost" < errors_today
fi
Last edited by elixir_sinari; 08-16-2012 at 10:28 AM..
This User Gave Thanks to elixir_sinari For This Post:
See elixir_sinari's solution including the date command. You can also leave out the count with -c and just check the return status of grep with $? or go this way, checking if the variable $VAR is not empty (to not invoke grep twice:
could you please do me a favor in writing the entire code snippet for me.
The spirit of the forum is to help of course, though we very welcome if posters seeking advice show some effort of their own, no matter how false it is.
You have some examples here now so please try to write the rest (if there is any) yourself and ask for particular problems if you get stuck. Please do not ask people to do the whole job for you
This is an excellent video comment on modern society and the remix is good too:
https://www.youtube.com/watch?v=5DU1B_XkyIk
5DU1B_XkyIk
Watch the video above and post your comments. (3 Replies)
If anyone could possibly help me to do this following question?
Print a long listing of the files in the login directory for a specific month.
The user is prompted to enter the first 3 letters of a month name, starting with a capital, and the program will display a long list of all files that... (1 Reply)
Hello everyone,
For a while now ive been wanting to create a way for me to access my home pc and have it perform remote tasks (Namely file downloading, archiving, torrenting) without needing to keep the PC continuously powered.
Having seen the power of Linux and ssh at the hands of... (1 Reply)
Hi
I have recently joined a bank as a tester. Initially I will be working on some test scripts and then I will be testing their data warehouse using SQL and Unix. I do have a very basic knowledge and understanding of both unix and sql. I am not sure how I will be using Unix to test their ... (2 Replies)
To anyone who asks which Unix is the best... or which one I should use...
Probably the best timeline I have ever seen.
Read this link... http://www.levenez.com/unix/history.html#08 (0 Replies)