Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Get domain names from IP addresses of apache2 access.log Post 302851487 by bakunin on Monday 9th of September 2013 05:24:21 AM
Old 09-09-2013
Quote:
Originally Posted by Ronni
Code:
cut -f 1 -d ' ' access.log | sort | uniq | ips.sh

But this does not do anything as of now and throws an error - ips.sh - command not found.
Let is start with this last piece: The reason why the system complains about not finding "ips.sh" is probably because it is not in the PATH: issue the following command:

Code:
echo $PATH

to see a list of directories separated by colons. Files in these directories you can call without using their full path (which is why you could use "cut" and "sort", etc.. They are all in "/usr/bin", which is in the PATH.), for all the others (this includes your current directory) you have to write:

Code:
cut -f 1 -d ' ' access.log | sort | uniq | /full/path/to/ips.sh

Another thing: sort | uniq is not necessary, because sort can do that too. Use the -u switch.

Code:
cut -f 1 -d ' ' access.log | sort -u | /full/path/to/ips.sh

Quote:
Originally Posted by Ronni
Code:
#!/bin/bash
while read junk 
do
         echo -n "$junk "         
         dig +short -x $junk 
done

This should work. I have no idea what dig does, but probably it displays something. You might want to quote "$junk" in the dig-line too. It will perhaps work anyway, but it is never too early to begin developing good habits and quoting variables to protect against them containing blanks is such a good habit.

For the same reason, you may want to define a variable before using it.

Code:
#!/bin/bash

typeset junk=""

while read junk 
do
         echo -n "$junk "         
         dig +short -x "$junk" 
done

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
 

9 More Discussions You Might Find Interesting

1. IP Networking

using unregistered domain names

hey what the hell happens if you make sure (as best one can) that a domain name like anything.com is not used at all, and you set up your own DNS and use that name without registering with a registrar, i know if the address is in use you will make some people very upset and give many internet users... (2 Replies)
Discussion started by: norsk hedensk
2 Replies

2. UNIX for Dummies Questions & Answers

Using Sendmail for multiple domain names

Hi, We're an internet company with several domain names. Our mail server was originally set up to deal with xxx@domain1.com email addresses which works fine. The problem I have is that we're now also using a domain2.com, and sales@domain1.com isn't the same as sales@domain2.com. I've added... (1 Reply)
Discussion started by: captainash
1 Replies

3. IP Networking

find computer names from IP addresses?

Arright, here's what I'm trying to do. I want to dig up currently active IP addresses on my subnet, and my present strategy is to ping every address until I find active ones, then ping them more often to verify their status. Next, I want to find the names of the computers associated with those... (1 Reply)
Discussion started by: sladuuch
1 Replies

4. Shell Programming and Scripting

please help, find domain names in string

Hello, i have a file contains the information like below /home/username/domain.com/log/access /home/username/domain23.net/log/access /home/reseller/username/domain.com/log/access using a loop i can read every line of the file but i wants to extract domain name like(domain.com,... (3 Replies)
Discussion started by: eyes_drinker
3 Replies

5. Shell Programming and Scripting

extracting domain names out of a text file

I am needing to extract and list domain names out of a very large text file. The text file contains tlds .com .net .org and others as well as third level domains e.g. host1.domain.com and the names are placed within paragraphs of text. Domains do not have a http:// prefix so I'm thinking the... (6 Replies)
Discussion started by: totus
6 Replies

6. Shell Programming and Scripting

How can i send mail to multiple addresses in same domain in bash?

Suppose i have a txt file that is the list of the addresses,something like: lala0045 john james lala0234 george james and i want to send an email to lala0045@blabla.com and lala0234@blabla.com,the same domain...what is the exact syntax i should use in my script? there is a command... (10 Replies)
Discussion started by: bashuser2
10 Replies

7. AIX

How do I restrict TFTP access to certain hosts/IP addresses?

Hi Everyone, I searched for an answer to this but couldn't find one so I'm hoping someone can lend some advice. My issue is that I have an AIX server running Sysback (for TSM backup/restore) and Sysback uses TFTP for sending the boot image to the client during a restore. A recent penetration... (2 Replies)
Discussion started by: need2bageek
2 Replies

8. Shell Programming and Scripting

Filter out IP addresses in domain resolve script

Hello everyone, I have written a one liner which looks in a configuration file for remote hosts to connect to. It then resolves them by first ping, and nslookup if it fails, then places the info in the hosts file. The whole thing works, seemingly, apart from one slight issue. I would like to... (0 Replies)
Discussion started by: haggismn
0 Replies

9. Solaris

Certain domain cannot access

hi there, im beginner in solaris 10. we are using solaris 10 as our DNS server Solaris 10 8/07 s10s_u4wos_12b SPARC Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms. ... (0 Replies)
Discussion started by: tappetmus
0 Replies
All times are GMT -4. The time now is 01:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy