help with /var folder

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions help with /var folder
# 1  
Old 12-06-2011
help with /var folder

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

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

Im trying to make a script which will · Use the /var/www/logs/access_log file to process the last 300 lines (i.e.) the lines at the end of the file (user opentech to test this option).



2. Relevant commands, code, scripts, algorithms:

so far Ive searched the directory for the /var/www/logs/access_log file but there is no /www directory or access_log directory
3. The attempts at a solution (include all code and scripts):



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
I currently attend Durham College Oshawa Canada Karl Alexander is my proffs name PROG3103. I dont have a link to the course website sorry :

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 12-06-2011
find /var/ -name 'access_log'
# 3  
Old 12-06-2011
Further to Corona688 who is showing you how to search the entire /var tree for a file called "access_log", this might need a deeper find if the file doesn't turn up easily.

First as user "root":
Code:
find /var/ -type f -xdev -follow -name access_log -print

There is a hint in the project that you must be user "opentech" to process this file, so "su" or "sudo" (if this is Linux) to the right user first before issuing your "tail -300" command. Actually changing user might well be enough to see the file "access_log". Try it out.
# 4  
Old 12-07-2011
k one more thing

im supposed too Display a list of IP addresses and the number of times a connection is made from that IP address
that would be done by using grep and wc on a the last 300 lines in this certain file in /var/www/logs/access log?

whats the command to display a list of IP's and number time connection as been made


Moderator's Comments:
Mod Comment No need to write it all bold and in a large font, thanks.

Last edited by zaxxon; 12-07-2011 at 08:07 AM.. Reason: font formattings
# 5  
Old 12-07-2011
Start by looking at the log to see how you would identify a line which contains a connection from an IP address. This will be the rule for your first grep. If the whole log is just connections you don't need this stage.

Then look at sample connection lines and come up with some simple way of defining where the IP address is on that line (e.g. 5th space-delimited field). This will dictate your method to extract the IP address prior to sorting and counting. (If you have not studied "awk" this might just involve using "cut").

If there is no clear rule to fish out the IP address then you could be looking at a grep which finds patterns like nnn.nnn.nnn (or nnn.nnn.nnn.nnn if this is IP6) where nnn is a number 0-255 . Let's hope it is a simple format log.

We don't know what your log file looks like. Can you post a couple of sample lines.


There is a current thread on this board which may get you started on how to count occurances in a list.
https://www.unix.com/unix-dummies-que...xist-file.html
# 6  
Old 12-07-2011
access=""
tail access_log -n 300 > access
access | grep "ip address" -c | wc -l


this is what i got so far just trying to see how i can identify the ip address part from this access log.....

· Display a list of IP addresses and the number of times a connection is made from that IP address

I also command too do this as well. without using the access_log
# 7  
Old 12-07-2011
Well, what do the contents of access_log look like?
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

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

2. Shell Programming and Scripting

Transfer the logs being thrown into /var/log/messages into another file example /var/log/volumelog

I have been searching and reading about syslog. I would like to know how to Transfer the logs being thrown into /var/log/messages into another file example /var/log/volumelog. tail -f /var/log/messages dblogger: msg_to_dbrow: no logtype using missing dblogger: msg_to_dbrow_str: val ==... (2 Replies)
Discussion started by: kenshinhimura
2 Replies

3. Shell Programming and Scripting

Csh , how to set var value into new var, in short string concatenation

i try to find way to make string concatenation in csh ( sorry this is what i have ) so i found out i can't do : set string_buff = "" foreach line("`cat $source_dir/$f`") $string_buff = string_buff $line end how can i do string concatenation? (1 Reply)
Discussion started by: umen
1 Replies

4. Shell Programming and Scripting

Find and replace folder of files with $var

I want to scan through all the files in the folder and replace all instances of $file_X within the file with the variable $X defined in my bash script on my debian 6.0 install. For example, if the file contains $file_dep I want it to be replaced with the value of the variable $dep defined in my... (1 Reply)
Discussion started by: Spadez
1 Replies

5. Solaris

Difference between /var/log/syslog and /var/adm/messages

Hi, Is the contents in /var/log/syslog and /var/adm/messages are same?? Regards (3 Replies)
Discussion started by: vks47
3 Replies

6. Solaris

/var/adm & /var/sadm

what is the difference between tha /var/adm and /var/sadm files in solaris 10 Os please can any one respond quickly thanking you (2 Replies)
Discussion started by: wkbn86
2 Replies

7. UNIX for Dummies Questions & Answers

Permissions of the folder var/www

what should be the permissions of the folder var/www in my ubuntu ? I need it to be safe and at the same time I need ftp users to be able to edit it. I was wondering if I should create a group with all permissions and add ftp users to this group in unix. what's the standard way to do it ?... (4 Replies)
Discussion started by: aneuryzma
4 Replies

8. Solaris

Lost /var/sadm/install/contents file and /var/sadm/pkg

Hello, I recently found that my /var/sadm/install/contents, ~/admin/default, /var/spool/patch and /var/spool/pkg files were empty. This broke the pkginfo, pkgchk and other package related tools. The pkgmap no longer points to where the applications have been installed. I have replaced the... (0 Replies)
Discussion started by: ronin42
0 Replies

9. Solaris

diff b/w /var/log/syslog and /var/adm/messages

hi sirs can u tell the difference between /var/log/syslogs and /var/adm/messages in my working place i am having two servers. in one servers messages file is empty and syslog file is going on increasing.. and in another servers message file is going on increasing but syslog file is... (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

10. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies
Login or Register to Ask a Question