Sponsored Content
Homework and Emergencies Homework & Coursework Questions Log file analyzer, super basic sh program Post 303009630 by malfiory on Sunday 17th of December 2017 09:56:55 AM
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)
Code:
#!/bin/sh

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!" ;;
esac

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
 

9 More Discussions You Might Find Interesting

1. Programming

basic math program 4 child

Iam writing a script for my sisters friends little brother i want the program to say hello lets say his name is Joe and ask him how he is and he can write a reply back saying fine and then it replys "Iam happy you are (his response) today and then it goes into a basic math where he can put in a... (9 Replies)
Discussion started by: perleo
9 Replies

2. HP-UX

BAD SUPER BLOCK - Run fsck with alternate super block number

Error received when I tried to restore a blank disk with an 'auto recovery' DDS tape via HP-UX recovery system 2.0 onto a 1Gb SCSI. I assumed it would do the setup, wrong. Could someone tell me the procedure to initial disk for recovering files using cpio. The system is a HP-UX 9.04 version on a... (1 Reply)
Discussion started by: admin wanabee
1 Replies

3. Shell Programming and Scripting

Having trouble writing a basic shell program

Hello. I'm trying to write a shell script that will take files that have .tar, .tar.gz, .tar.Z, .gz, .Z and .zip file extensions and uncompress and unarchive them. The script should be able to take multiple arguments. So far I can write a script using the case command that will do this but it will... (3 Replies)
Discussion started by: SeanWuzHere
3 Replies

4. Programming

Basic multithreaded program

I'd like to write a program (I'm flexible on language; C/C++ was my original idea but a scripting language would probably be better) that runs hundreds of programs, but only N = 4 (say) at a time. The idea is to keep all the cores on a multicore machine busy. How can I do this? In particular,... (6 Replies)
Discussion started by: CRGreathouse
6 Replies

5. HP-UX

Program monitor on BT-Basic

Hi, The "program monitor" command in BT-Basic prompt you for a user name and a password. How can I grant access only to certain users ? Thank you. (0 Replies)
Discussion started by: fosiceanu
0 Replies

6. IP Networking

Best iptables log analyzer?

Hello all, i want to view my iptables log on web interface, with chart (in option, and this is not my priority). What is the best program for this? I have Ubuntu server. Thanks ! :) (0 Replies)
Discussion started by: Pacifiste95
0 Replies

7. Infrastructure Monitoring

Centralized linux system log analyzer?!

Hello everyone! I`m searching for linux log parser application. I already find some ways, but the best looks logzilla. Requirements: Web interface for viewing Filtering in web Notifications in web or email Open source Support linux system logs, custom logs and apache logs. I will... (5 Replies)
Discussion started by: jabalv
5 Replies

8. Homework & Coursework Questions

Need help with Basic Unix Program

I am a newbie to UNIX. I'm learning UNIX on my own, just trying to get the jerk of how things work in UNIX environment. I am familiar with Windows environment. Can anyone pls write simple 'envprint' programs to : 1) List all the environment Information (using the -l or --l options) 2) ... (1 Reply)
Discussion started by: agup17
1 Replies

9. Shell Programming and Scripting

Log file analyzer, super basic sh file

Hello! I have a small shell project that is due next week, that I'd appreciate some help with. task: Write a shell program that can analyze at least 2 types of log files and print them in an easily readable way. Make it so that you can switch between log file types. The two file types should be... (1 Reply)
Discussion started by: malfiory
1 Replies
SINCE(1)							   User Manuals 							  SINCE(1)

NAME
since - display content of a file since the last time SYNOPSIS
since [-aefhlmnqvxz] [-d seconds] [-s file] files DESCRIPTION
since is a utility designed to monitor log files. since is similar to tail(2) as it also displays information appended to a file. However since only displays the data which has been added since the last time since was run. If since is run on a particular file for the first time, then the entire file is displayed. EXAMPLE
since /var/log/apache/{access,error}_log > /dev/null lynx --dump http://localhost/ > /dev/null since /var/log/apache/{access,error}_log OPTIONS
-a Make updates to the since state files atomic. This option configures since to use a temporary file and a rename(2) instead of updat- ing the state file in situ. -d seconds Specify the number of integer seconds to wait between polling files for changes. This option is only relevant in conjunction with the -f option and if the inotify mechanism is not being used. -e Print the header lines to standard error instead of standard output. -f Follow the specified files. This option is analogous to tail -f as the files are also polled for changes until the process is inter- rupted. -h Print a terse help message. -l Relaxed mode. If some data files are inaccessible since will not fail completely. -m Disable mmap(2), use read(2) instead to access state and data files. Note that for certain smaller io operations read(2) may be used even if this option has not been given. -n Do not update the .since file which keeps track of file growth. -q Make the utility operate more quietly. -s filename Specify the state file explicitly. Using this option will also disable the use of fallback state files. -v Increase the verbosity. This option can be given multiple times. -x Ignore file arguments which have compressed extensions. -z Discard output. Similar to redirecting the output to /dev/null, but faster. If used in conjunction with the -f option, only the ini- tial output will be discarded. FILES
.since State file recording the length of the previously displayed files. The location of the file can be set on the command line using the -s option. If this option is not given, since will check the SINCE environment variable for the location of the state file. If the SINCE environment variable has not been set since will use the HOME environment variable and store the information in the file $HOME/.since. If the HOME variable is not set, since will use a getpwuid(3) lookup. If all these fail will use the file /tmp/since. BUGS
since uses the inode of a file as its key, if that inode is recycled since will get confused. since is not particularly efficient when storing or looking up the stat(2) information. Functionality equivalent to since can probably be achieved with a number of trivial shell scripts. COPYING
since may only be used, distributed and modified in accordance with the terms of the GPL (GNU General Public License) version 3 or newer as published by the FSF (Free Software Foundation). SEE ALSO
tail(1), stat(2). Linux JULY 1998 SINCE(1)
All times are GMT -4. The time now is 10:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy