Home Man
Today's Posts

Students must use and complete the template provided. If you do not use the template your post may be deleted! Special homework rules apply here.

Log file analyzer, super basic sh program

Login to Reply

Thread Tools Search this Thread
# 1  
Old 12-17-2017
Log file analyzer, super basic sh program

Hello! I'd like some help with this assignment.

1. The problem statement, all variables and given/known data:

1)Write a shell script that can uses two types of files as inputs, apache.log and apache.error.log
2)Make it so that you can switch between the two file types
3)Make it so that the script writes the output in the terminal, and it is easily readable (use whitespace characters to separate the columns)

2. Relevant commands, code, scripts, algorithms:
awk commands

3. The attempts at a solution (include all code and scripts):
for task 2)

echo "What type of file's contents would you like for me to print? 1 - apache.log, 2 - apache.error.log"
read NUM

case $NUM in
	1) # Print out apache.log's contents ;;
	2) # Print out apache.error.log's contents ;;
	*) echo "INVALID INPUT!" ;;

I don't know how I could do task 3)

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of Miskolc, Miskolc, Hungary, Smid László, GE-BGI
# 2  
Old 12-17-2017
Welcome to the forum.

Not bad a start. You now could use shell functions to fulfill the 3rd requirement. I'm not sure what that exactly is, but just copying the files to the terminal might be missing it. Wouldn't it be helpful to provide small but representative samples of either log file if you need further assistance?
# 3  
Old 12-18-2017
Oh yeah, sorry.

for apache.log
x.x.x.90 - - [13/Sep/2006:07:01:53 -0700] "PROPFIND /svn/[xxxx]/Extranet/branches/SOW-101 HTTP/1.1" 401 587
x.x.x.90 - - [13/Sep/2006:07:01:51 -0700] "PROPFIND /svn/[xxxx]/[xxxx]/trunk HTTP/1.1" 401 587
x.x.x.90 - - [13/Sep/2006:07:00:53 -0700] "PROPFIND /svn/[xxxx]/[xxxx]/2.5 HTTP/1.1" 401 587
x.x.x.90 - - [13/Sep/2006:07:00:53 -0700] "PROPFIND /svn/[xxxx]/Extranet/branches/SOW-101 HTTP/1.1" 401 587
x.x.x.90 - - [13/Sep/2006:07:00:21 -0700] "PROPFIND /svn/[xxxx]/[xxxx]/trunk HTTP/1.1" 401 587
x.x.x.90 - - [13/Sep/2006:06:59:53 -0700] "PROPFIND /svn/[xxxx]/[xxxx]/2.5 HTTP/1.1" 401 587
x.x.x.90 - - [13/Sep/2006:06:59:50 -0700] "PROPFIND /svn/[xxxx]/[xxxx]/trunk HTTP/1.1" 401 587
x.x.x.90 - - [13/Sep/2006:06:58:52 -0700] "PROPFIND /svn/[xxxx]/[xxxx]/trunk HTTP/1.1" 401 587
x.x.x.90 - - [13/Sep/2006:06:58:52 -0700] "PROPFIND /svn/[xxxx]/Extranet/branches/SOW-101 HTTP/1.1" 401 587

for error
[Fri Dec 16 01:46:23 2005] [error] [client] Directory index forbidden by rule: /home/test/
[Fri Dec 16 01:54:34 2005] [error] [client] Directory index forbidden by rule: /apache/web-data/test2
[Fri Dec 16 02:25:55 2005] [error] [client] Client sent malformed Host header
[Mon Dec 19 23:02:01 2005] [error] [client] user test: authentication failure for "/~dcid/test1": Password Mismatch

# 4  
Old 12-18-2017
Use a pager like more or less to display the files on screen.
# 5  
Old 12-18-2017
I want the script to take an input like
./analyzer.sh 1 access_log

and print its contents.
Also to check if access_log is in the correct apache.log format, and if it isn't give back an error message.

I don't know how I could make that.
# 6  
Old 12-18-2017
Do you want to read the log type from terminal, or do you want to pass it from the command line?
Do you know how to get at the script's positional parameters?
How would you describe the respective files' format, so it can be compared / controlled?
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Log file analyzer, super basic sh file malfiory Shell Programming and Scripting 1 12-17-2017 08:39 AM
Super Simple Script to remove first characters of any png file pasc Windows & DOS: Issues & Discussions 17 03-07-2013 04:44 PM
Need help with Basic Unix Program agup17 Homework & Coursework Questions 1 04-06-2012 11:55 AM
Best iptables log analyzer? Pacifiste95 IP Networking 0 07-14-2011 03:14 PM
Program monitor on BT-Basic fosiceanu HP-UX 0 07-16-2010 04:42 AM
Basic multithreaded program CRGreathouse Programming 6 06-14-2009 04:53 PM
Having trouble writing a basic shell program SeanWuzHere Shell Programming and Scripting 3 11-30-2006 12:41 PM
BAD SUPER BLOCK - Run fsck with alternate super block number admin wanabee HP-UX 1 09-08-2006 01:57 PM
basic math program 4 child perleo Programming 9 10-22-2002 04:51 PM

All times are GMT -4. The time now is 02:01 PM.

Unix & Linux Forums Content Copyrightİ1993-2018. All Rights Reserved.
Show Password