how do i perform an reverse dns lookup?
I am attempting to try to write a perl script that will print stats to an email, now I need to do a reverse dns lookup because the computers are stored in the log file as IP addresses. The powers to be want the PC name not the address. I know the commands to do it, host, nslookup and dig. host and nslookup seem to have the most promise. How would i word either of those commands with options to get just the pc name and not the other info???
|
I don't know about an option that will cause host or nslookup to give you what you want, but you may try this:
host <ip> | awk '{print $NF}' | head -c -2 You may also implement this string manipulation in perl instead of using pipes :) |
Code:
host <ip> | awk '{print $NF}' what i have is the IP address from a CSV log file and it is in the form of \\1.2.3.4 and It is in the array it is $a[6] Code:
$a[6] = (split(/\\/, $a[6])); and to set a variable with the system command would be: Code:
$host = "system 'host $ip | awk '{print $NF}''"; |
The following code appears to work
Code:
$a[6] = "\\\\1.2.3.4"; |
Code:
($pcname) = (split(/\\/, $pcname))[2]; however running this command doesn't work correctly in perl however it does in the command. There has to be a better way to run a mutli command line in perl without setting it to another variable. here is the code that doesn't work, the first part works however it seem to ignore the | awk part. How do i get it to not ingore it? : Code:
system("host $ip | awk \'{print $NF}\'"); |
All times are GMT -5. The time now is 12:20 PM. |