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
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
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
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
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
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
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
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
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
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
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
tclsh(1) Tcl Applications tclsh(1)
__________________________________________________________________________________________________________________________________________________
NAME
tclsh - Simple shell containing Tcl interpreter
SYNOPSIS
tclsh ?-encoding name? ?fileName arg arg ...?
_________________________________________________________________
DESCRIPTION
Tclsh is a shell-like application that reads Tcl commands from its standard input or from a file and evaluates them. If invoked with no
arguments then it runs interactively, reading Tcl commands from standard input and printing command results and error messages to standard
output. It runs until the exit command is invoked or until it reaches end-of-file on its standard input. If there exists a file .tclshrc
(or tclshrc.tcl on the Windows platforms) in the home directory of the user, interactive tclsh evaluates the file as a Tcl script just
before reading the first command from standard input.
SCRIPT FILES
If tclsh is invoked with arguments then the first few arguments specify the name of a script file, and, optionally, the encoding of the |
text data stored in that script file. Any additional arguments are made available to the script as variables (see below). Instead of
reading commands from standard input tclsh will read Tcl commands from the named file; tclsh will exit when it reaches the end of the
file. The end of the file may be marked either by the physical end of the medium, or by the character, "