Firstly, I do apologize that my first post here is a question. I am quite familiar with UNIX since our application is running on it. We are trying to automate a few things on our end and I am challenged with a task in hand that requires UNIX scripting. I am totally a newbie in UNIX scripting and I have started learning it but this task seems to be a little complex for me.
Put that in a file, maybe name it checklog, use chmod to make it executable and use it like this:
checklog logfile
If the argument file doesn't exist, test -f will return 1 without doing the grep.
If the file exists and the quoted text is not found, grep will quietly return 1.
If both tests succeed, 0 is returned.
This code looks very straight-forward but the only problem is this particular log file will have entries for past executions as well. I am going to try to keep separate log file for different 'Events' to avoid the log file from capturing mutiple 'Event' executions at the same time.
I am jut throwing this idea out there, can we have a secondary log file which is generated from the master log file but it only captures the current execution with an override function? if this is somewhat possible we can potentially have the script you built to go against the secondary log file all the time.
This does sound a little complex to me, let me know what you think?
Here's a slight modification that uses grep to find all the execution completed lines and pipe them to tail, which only passes on the last one. Finally, grep tests to see if it was successful. So this will give a result of the last entry in the file.
If I should try to embed this code on my existing Unix script file (TR01.scp) which I created to trigger the event (See the Code Below)
ksh /export/home/install/bin/mstrcmdmgr
-n DEV -u ABC -p xxxx
-f /export/home/mstr/Trigger/Event/EV01.scp
-o /export/home/mstr/Trigger/Logs/File_Output.scp
######
-f = Location of the Event script
-o = Location of the log file which will get generated
######
Since your code does not specifiy the location of the log file to perform the grep, I am not sure where to place this file.
Ideally, I would like to see the return code when I execute the TR01.scp
Thanks for all your help Ken!!
---------- Post updated at 03:05 PM ---------- Previous update was at 08:56 AM ----------
Ken -
I finally broke the deadlock... of course your idea was the inpiration to begin with. I tweaked it a little after getting some additional ideas. The script is as below;