Sponsored Content
Top Forums Shell Programming and Scripting Writing a UNIX script from LOG to provide return code. Post 302512811 by sk72 on Monday 11th of April 2011 04:29:43 PM
Old 04-11-2011
Writing a UNIX script from LOG to provide return code.

Folks -

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.

I have the following log entry

##SAMPLE OF SUCCESSFUL LOG ENTRY##
4/11/11 3:19:07 PM EDT Version x.x.x
4/11/11 3:19:07 PM EDT Project Source Name: XYZ
4/11/11 3:19:07 PM EDT Login: ABC
4/11/11 3:19:07 PM EDT Executing task(s)...
4/11/11 3:19:07 PM EDT Checking syntax...
4/11/11 3:19:08 PM EDT Syntax is correct.
4/11/11 3:19:08 PM EDT Syntax checking has been completed.
4/11/11 3:19:08 PM EDT Event 'TEST' has been triggered successfully.
4/11/11 3:19:08 PM EDT No results returned.
4/11/11 3:19:08 PM EDT Task(s) execution completed successfully.
4/11/11 3:19:08 PM EDT Execution Time: 00:00:00
4/11/11 3:19:08 PM EDT Successfully disconnected. (MSTR) XYZ:ABC
#####################################################

##SAMPLE OF UN-SUCCESSFUL LOG ENTRY##
4/5/11 4:17:17 PM EDT Version x.x.x
4/5/11 4:17:17 PM EDT Project Source Name: XYZ
4/5/11 4:17:17 PM EDT Login: ABC
4/5/11 4:17:17 PM EDT Executing task(s)...
4/5/11 4:17:17 PM EDT Checking syntax...
4/5/11 4:17:17 PM EDT Syntax is correct.
4/5/11 4:17:17 PM EDT Syntax checking has been completed.
4/5/11 4:17:17 PM EDT (You do not have DssPrivilegesFireEvent privilege that is required to perform the task.)
4/5/11 4:17:17 PM EDT No results returned.
4/5/11 4:17:17 PM EDT Task(s) execution completed with errors.
4/5/11 4:17:17 PM EDT Execution Time: 00:00:00
4/5/11 4:17:17 PM EDT Successfully disconnected. (MSTR) XYZ: ABC
###################################################################


I need to somehow develop a UNIX script which will read the red line bolded in red above into

1. 'Return Code' of ='0' for successful execution
2. 'Return Code' of ='1' for un-successful execution

This log file will capture log information for all UNIX scripts which has been triggerred for the application I am monitoring.

I am open to discussion and design which you think will be the best method of approach to handle this task.

Thanks a lot
-Sree
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in writing a unix script

OS: Solaris Shell : KSH Please help me in writing a script that captures a error message from a log file ( which updates continiously ) and send an email alert as soon as the systems throws a error message into that log. i.e With out monitoring the log Thanks in advance.. (1 Reply)
Discussion started by: pray44u
1 Replies

2. Shell Programming and Scripting

return code of a unix command

How to find out whether the command I executed is successful or unsuccessful(at commandlinet) Eg: say i execute the following command at command line rm * How do i find out whether my previous command is a success or failure. Thankyou. Best Regards, Ram. (1 Reply)
Discussion started by: ramky79
1 Replies

3. Shell Programming and Scripting

return code from script

hey all, I have a simple script #!/bin/bash ./cron.sh test_a.txt & ./cron.sh test_b.txt & wait I want to invoke another program based on the return status of the above calls. How am I were to get that? Thanks! (2 Replies)
Discussion started by: mpang_
2 Replies

4. UNIX for Dummies Questions & Answers

Perl Unix Script Writing

Hi Folks, I posted a few days ago, thanks for the responses. My original question was for renaming files of sort 3p2325294.dgn in a directory containing multiple files. I need to drop the first 2 characters and the last in a unix script using Perl. How does it differ from using the Unix... (1 Reply)
Discussion started by: Dinkster
1 Replies

5. Shell Programming and Scripting

help writing this unix script

I am working on writing scripts. Here is a script I need help with. I have also wrote what I think it is. I would really appreciate any help that I can get. Create an executable script file called "newname" that will perform the followings: 1. Rename a file upon the user's request. If the... (2 Replies)
Discussion started by: wiggles
2 Replies

6. Shell Programming and Scripting

need help writing this unix script

Create an executable script file called "newname" that will perform the followings: 1. Rename a file upon the user's request. If the file exists, prompt the user for confirmation before renaming the file. The screen should prompt the user for a. "Name of file you want to rename." Use the "\c"... (7 Replies)
Discussion started by: wiggles
7 Replies

7. Shell Programming and Scripting

Pointers on writing a unix script

Hi All, I am writing a unix shell script. I have a file called Results.txt which stores 4 fields separated by pipe. i.e. a pipe delimited file. I want to loop through each record of this file and store each of these 4 fields into variables. I have read can be done through awk but I have never... (7 Replies)
Discussion started by: shwetainnani
7 Replies

8. HP-UX

return code from oracle to unix script

Hi I'm writing a shell script that connects to oracle database and fires query to check the availability of data in a table. In case of no data found then what will be the return code and how to handle in that in variable. Kindly provide with an example for better understanding... Thanks... (1 Reply)
Discussion started by: ksailesh
1 Replies

9. Shell Programming and Scripting

Unix return code example

Hi, Does anyone here can guide me to understand how is return code works in a parent-child relation with a simple example? I have a request to build the script with return code in a child script, but i want to understand how does child script can return a code to the parent, stated if its... (4 Replies)
Discussion started by: khchong
4 Replies

10. Shell Programming and Scripting

Need to get return code from mutt if an address is invalid/undeliverable from Unix shell script

I am using mutt on ksh Unix to send emails to addresses plucked from the database. If the "To:" email address is not longer valid and so the email is not sent to the "To:" recipient, but is sent to the valid cc address, I need to be able to get an error code returned to the shell script so that... (3 Replies)
Discussion started by: jzuber
3 Replies
tztab(4)						     Kernel Interfaces Manual							  tztab(4)

NAME
tztab - time zone adjustment table for date and ctime() DESCRIPTION
The file describes the differences between Coordinated Universal Time (UTC) and local time. Several local areas can be represented simul- taneously with historical detail. The file consists of one or more time zone adjustment entries. The first line of the entry contains a unique string that may match the value of the string in the user's environment. The format is where is the time zone name or abbreviation, diff is the difference in hours from UTC, and is the name or abbreviation of the "Daylight Savings" time zone. Fractional values of diff are expressed in minutes preceded by a colon. Each such string will start with an alphabetic character. The second and subsequent lines of each entry details the time zone adjustments for that time zone. The lines contain seven fields each. The first six fields specify the first minute in which the time zone adjustment, specified in the seventh field, applies. The fields are separated by spaces or tabs. The first six are integer patterns that specify the minute (0-59), hour (0-23), day of the month (1-31), month of the year (1-12), year (1970-2038), and day of the week (0-6, with 0=Sunday). The minute, hour, and month of the year must contain a number in the (respective) range indicated above. The day of the month, year, and day of the week can contain a number as above or two numbers separated by a minus (indicating an inclusive range). Either the day of the month or the day of the week field must be a range, the other must be simple number. The seventh field is a string that describes the time zone adjustment in its simplest form: where is an alphabetic string giving the time zone name or abbreviation, and diff is the difference in hours from UTC. must match either the field or the field in the first line of the time zone adjustment entry. Any fractional diff is shown in minutes. Comments begin with a in the first column, and include all characters up to a newline. Comments are ignored. EXTERNAL INFLUENCES
International Code Set Support Single-byte character code sets are supported. EXAMPLES
The time zone adjustment table for the Eastern Time Zone in the United States is: Normally (as indicated in the first line) Eastern Standard Time is five hours earlier than UTC. During Daylight Savings time, it changes to a 4 hour difference. The first time Daylight Savings Time took effect (second line) was on January 6, 1974 at 3:00 a.m., EDT. Note that the minute before was 1:59 a.m., EST. The change back to standard time took effect (sixth line) on the last Sunday in November of the same year. At that point, the time went from 1:59 a.m., EDT to 1:00 a.m., EST. The transition to Daylight Savings Time since then has gone from the last Sunday in February (third line) to the last Sunday in April (fourth line) to the first Sunday in April (fifth line). The return to standard time for the same period has remained at the last Sunday in October (seventh line). AUTHOR
was developed by HP. FILES
SEE ALSO
date(1), ctime(3C), environ(5). tztab(4)
All times are GMT -4. The time now is 11:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy