Include logfile in scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Include logfile in scripts
# 1  
Old 09-23-2013
Include logfile in scripts

I am also pretty new to this scripting as well. I have found some bash script files from a legacy software. I need to find out the meaning. Could anyone help me regarding the following line:

Code:
LOGFILE=/export/home/test/log/test1.log

where and how this log file is being saved and why this line is required to write scripts in UNIX environment?

Very eagerly waiting. Thanking in advance.

Last edited by Scott; 09-23-2013 at 03:32 PM.. Reason: Code tags
# 2  
Old 09-23-2013
It sets a variable named LOGFILE to the string "/export/home/test/log/test1.log".

That is all.

How the logfile is created and written to, is up to the entire rest of the script you didn't post. Smilie We need more!
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 09-23-2013
Thank you Corona688.

What the following lines mean:
Code:
RETURNCODE=$?
echo "Success: $RETURNCODE" >>$LOGFILE
echo "Update complete `date`" >>$LOGFILE
exit $RETURNCODE


Last edited by Franklin52; 09-24-2013 at 03:12 AM.. Reason: Please use code tags
# 4  
Old 09-23-2013
Code:
# Get the return code of the last program that ran
# 0=success, anything else = error.
RETURNCODE=$?
# Print the return code and append it to $LOGFILE.
echo "Success: $RETURNCODE" >>$LOGFILE
# Print message and date, and append to $LOGFILE.
echo "Update complete `date`" >>$LOGFILE
# Return the same returncode we got above.
exit $RETURNCODE

This User Gave Thanks to Corona688 For This Post:
# 5  
Old 09-23-2013
Quote:
Originally Posted by Corona688
Code:
# Get the return code of the last program that ran
# 0=success, anything else = error.
RETURNCODE=$?
# Print the return code and append it to $LOGFILE.
echo "Success: $RETURNCODE" >>$LOGFILE
# Print message and date, and append to $LOGFILE.
echo "Update complete `date`" >>$LOGFILE
# Return the same returncode we got above.
exit $RETURNCODE



Thank you Corona688.
So, the only way to identify whether there is any error is to check the RETURNCODE. If it is '0' then success, otherwise Error, isn't it?
# 6  
Old 09-23-2013
It will be a number from zero to 255 inclusive. Usually it's limited to zero or one, but programs may return specific numbers for specific errors too. What error they mean is up to the program.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logfile monitoring with logfile replacement

Bonjour, I've wrote a script to monitor a logfile in realtime. It is working almost perfeclty except for two things. The script use the following technique : tail -fn0 $logfile | \ while read line ; do ... some stuff done First one, I'd like a way to end the monitoring script if a... (3 Replies)
Discussion started by: Warluck
3 Replies

2. Shell Programming and Scripting

Logs from logfile

Hi Team, Have to write a shell script to pick only 1 hr logs from the generated logfile and send it to other logfile. Thanks & Regards, Indu (3 Replies)
Discussion started by: indira_s
3 Replies

3. Shell Programming and Scripting

Parsing Logfile

Hi, I need to continuously monitor a logfile to get the log information between a process start and end. the logfile look like this abcdddddddddd cjjckkkkkkkkkkkk abc : Process started aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbb abc... (6 Replies)
Discussion started by: Byorg
6 Replies

4. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

5. UNIX for Dummies Questions & Answers

shell scripts - list dead users accts and include a count at the end?

I am trying to show the number of dead accts or false shells running and include a count at the end. Does anyone know how to go about this? Thanks - citizencro (3 Replies)
Discussion started by: citizencro
3 Replies

6. UNIX for Dummies Questions & Answers

change value of logfile

Hi, I have a log file like exyymmdd.log and i need to do is read the log file and inside the logfile if i find the word which starts with PQR002106570.book then i need to replace the value of PQRXXX.book(this is unique) with its corresponding title. A list of id(PQRXXX.book) and its title are... (5 Replies)
Discussion started by: umapearl
5 Replies

7. Shell Programming and Scripting

logfile parsing

I thought I was pretty handy with awk until I got this one. :) I'm trying to parse a log file where the events could have different delimiters (2 scripts is ok), the errors are spread over multiple lines, and I"m trying to figure out how to not read the same lines that have already been read. ... (1 Reply)
Discussion started by: linkslice
1 Replies

8. UNIX for Dummies Questions & Answers

Logfile manipulation

Hi First of all I m a complete newbie to Linux ... just started working on it exactly a week ago. I know a bit of programming in C but not very good in it.:D I was given task in my workplace and need some help nAJLR02F030879 9805 Thu Nov 19 13:27 <customerservice@YYY.com> ... (2 Replies)
Discussion started by: abilash.amara
2 Replies

9. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

10. Shell Programming and Scripting

logfile

hi iam new of the ksh script.iwant in formation of how to call in logfile in ksh scripts. if the meaning in ksh. please help me thanks naveen.g (1 Reply)
Discussion started by: naveeng.81
1 Replies
Login or Register to Ask a Question