How to write a bourne shell to do with logfiles??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to write a bourne shell to do with logfiles??
# 1  
Old 05-05-2010
How to write a bourne shell to do with logfiles??

Hi,I have a task have to do is writing an only Bourne shell to do with logfiles.
Because I am not really a programmer,just unix administrator.
So I need someone can do this for me.

The requirement is
1,be able to run in an environment that does not include a path. (i.e. the environment provided by cron)

2,accept the name of a logfile as the sole command line argument

3,search the specified logfile for lines that have been added since the previous search.

4,construct an e-mail reporting any lines that contain either "error" or "warning" in any combination of upper and lower case letters

5,send the e-mail to the address specified in the RECIPIENT shell variable which is defined within the script

Last edited by Franklin52; 05-05-2010 at 12:36 PM.. Reason: removed e-mail address
# 2  
Old 05-05-2010
Quote:
Originally Posted by lemon_06
Hi,I have a task have to do is writing an only Bourne shell to do with logfiles.
Because I am not really a programmer,just unix administrator.
So I need someone can do this for me.

The requirement is
1,be able to run in an environment that does not include a path. (i.e. the environment provided by cron)

2,accept the name of a logfile as the sole command line argument

3,search the specified logfile for lines that have been added since the previous search.

4,construct an e-mail reporting any lines that contain either "error" or "warning" in any combination of upper and lower case letters

5,send the e-mail to the address specified in the RECIPIENT shell variable which is defined within the script
We want to help you if you have shown that you have put some effort into solving your problem but not to do your work for you, we are not a helpdesk service.

On the other hand, this really smells like homework to me.
# 3  
Old 05-05-2010
Quote:
Originally Posted by lemon_06
Hi,I have a task have to do is writing an only Bourne shell to do with logfiles.
Because I am not really a programmer,just unix administrator.
So I need someone can do this for me.

The requirement is
1,be able to run in an environment that does not include a path. (i.e. the environment provided by cron)
Easy enough. Just have the script fix its own path.
Code:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin"

Quote:
3,search the specified logfile for lines that have been added since the previous search.
What if the logfile's been truncated since last time it ran?

Cron output should be automatically mailed without doing anything special if cron is configured correctly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Cybersecurity

'Shell Shock' vulnerability in Bourne shell

A severe vulnerability was discovered in Bourne shell. Just google for: bash vulnerability ... for more details. (5 Replies)
Discussion started by: Cochise
5 Replies

2. UNIX for Dummies Questions & Answers

Bourne shell tutorial

hey guys, what is prolly the best way to learn bourne shell programming the easy way? I found many tutorials but I just cant seem to decide / chose which one is the best and suits my needs. could you recommend me some tutos? thanks (1 Reply)
Discussion started by: genius90
1 Replies

3. Shell Programming and Scripting

Bourne shell & Korn shell

Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command .. $ echo $SHELL yields me /bin/sh Does this tells me that I am in Bourne shell. If yes, how can i get... (6 Replies)
Discussion started by: bobby1015
6 Replies

4. Shell Programming and Scripting

Bourne/C shell help

Exercise Five Write a Bourne shell script which: • Professionalism: plan for this from the start. • Has one command line argument. • If the command line argument is a directory then the script should output the number of files in the directory. • If the command line argument is an ordinary... (2 Replies)
Discussion started by: moesom
2 Replies

5. Shell Programming and Scripting

help with bourne shell script

Attempting to write a script to eventually notify me via email for when there is packetloss across the backbone. I am looking for values greater than 0% in the mtr field. #!/bin/sh target=www.google.com date +"%D"_"%T" >> /home/rich/mtr.log echo "----------------------------------------" >>... (1 Reply)
Discussion started by: closedown
1 Replies

6. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

7. Shell Programming and Scripting

I need to understand the differences between the bash shell and the Bourne shell

I do not claim to be an expert, but I have done things with scripts that whole teams of folks have said can not be done. Of course they should have said we do not have the intestinal fortitude to git-r-done. I have been using UNIX actually HPUX since 1992. Unfortunately my old computer died and... (7 Replies)
Discussion started by: awk_sed_hello
7 Replies

8. Shell Programming and Scripting

split monthly logfiles into daily logfiles

Hi, I have a lot of logfiles like fooYYYYMM.log (foo200301.log, foo200810.log) with lines like YYYY-MM-DD TIMESTAMP,text1,text2,text3... but I need (for postprocessing) the form fooYYYYMMDD.log (so foo200402.log becomes foo20040201.log, foo20040202.log...) with unmodified content of lines. ... (1 Reply)
Discussion started by: clzupp
1 Replies

9. UNIX for Dummies Questions & Answers

Bourne-again shell

Hi guys !! well i'm still new in learning UNIX , and actually i'm still studying it by myself .. anyway, some people told me the Bourne-again shell is a good version of UNIX to work on , and i tried to download yesterday but i didn't know how to start it ...... the ReadMe file associated with... (3 Replies)
Discussion started by: mrsamer
3 Replies

10. UNIX for Dummies Questions & Answers

Bourne Shell Script

Hello, I'm throwing this out there as a novice to the Unix world...I've been working on a project that requires me to ouput (using the echo command) a list of names in a single column format, but the problem is the input is in row format followed by a blank space...If anyone could give me a... (2 Replies)
Discussion started by: dmhonor914
2 Replies
Login or Register to Ask a Question