Sponsored Content
Full Discussion: Script Idea's / Help
Top Forums Shell Programming and Scripting Script Idea's / Help Post 302235880 by redoubtable on Saturday 13th of September 2008 01:47:54 PM
Old 09-13-2008
No need for external programs. Perl does the look-up for you:
Code:
 perl -ne 'use Socket; print "".(gethostbyaddr(inet_aton($1), AF_INET) or "Unknown ip bla bla")."\n" if /((?:\d{1,3}\.){3}\d{1,3})/;' ip-file

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Limitations of awk? Good idea? Bad idea?

Keeping in mind that I'm relatively comfortable with programming in general but very new to unix and korn/bourne shell scripts.. I'm using awk on a CSV file, and then performing calculations and operations on specific fields within specific records. The CSV file I'm working with has about 600... (2 Replies)
Discussion started by: yongho
2 Replies

2. Shell Programming and Scripting

idea for script - cheking passwords

Hi All, I am looking for scripts where i need check normal user password and root password for more 100 servers from single server...! let me explin it what exacltly i need...! i need to do password audit for more than 600 boxes... :o for one normal user and root password also...... (5 Replies)
Discussion started by: bullz26
5 Replies

3. Shell Programming and Scripting

An curious idea, how to make it by the powerful script?

I use a simple script to do some quantum calculations with gaussian package. the script as follows #!/bin/sh #put a gaussian input file into a new folder in the same name #and submit this new job for i in *.gjf do FN=$( echo $i | sed 's/.gjf//') mkdir $FN mv... (1 Reply)
Discussion started by: liuzhencc
1 Replies

4. Shell Programming and Scripting

Bash script idea using cUrl -- possible?

I have an alias already in my .bash_profile to download files using cUrl's -o (output to file, user provides the file name) option. I find I'm using it quite a bit, so I wanted to write a script to run "curl -o", taking the necessary inputs - file name and URL from which to download - and then... (3 Replies)
Discussion started by: SilversleevesX
3 Replies

5. Shell Programming and Scripting

Help with the idea of a script to modify time

Hello friends, I need an idea or a ready solution for a problem i have the following lines in text file: 1 20100920140122 object4 MOVE IN 2 20100920150012 object4 MOVE OUT -- cut -- the second column is the date and time: 20100920140122 = 2010 09 20 14:01.22 what I need to do is to add 40... (8 Replies)
Discussion started by: peetteerr
8 Replies

6. Shell Programming and Scripting

need a new idea for a script

Hi all, I now have project in UNIX Solaris and I want to have some new ideas to execute it, so I hope you help me finding new ideas in scripting or some infrastructure .bye (1 Reply)
Discussion started by: hard_revenge
1 Replies

7. Shell Programming and Scripting

Idea needed regarding process related script

I want to write a script which will take two time as input parameters and display the details of running processes between the two times, any ideas about the script ? (6 Replies)
Discussion started by: sandip250382
6 Replies

8. Shell Programming and Scripting

Compact script with array - Good idea?

Hi, I have a shell script where a lot of the code is repeated. I wanted to make the code much more compact so I spoke to a guy and he suggested using arrays, like follows: #!/bin/bash readonly -a nginx=('nginx' '--prefix=/opt' '-j 4' 'http://nginx.org/download/nginx-1.2.2.tar.gz' )... (2 Replies)
Discussion started by: Spadez
2 Replies

9. Shell Programming and Scripting

I have no idea what is wrong with my simple script.

I am doing a simple "recycle bin" script. It is to check and see if the directory .TRASH exists within the home directory. If not then it makes the directory then appends a date and time to file and then finally moves the file in. However, when I run this script, it is not making the directory as... (5 Replies)
Discussion started by: iamdeman
5 Replies
Net::hostent(3pm)					 Perl Programmers Reference Guide					 Net::hostent(3pm)

NAME
Net::hostent - by-name interface to Perl's built-in gethost*() functions SYNOPSIS
use Net::hostent; DESCRIPTION
This module's default exports override the core gethostbyname() and gethostbyaddr() functions, replacing them with versions that return "Net::hostent" objects. This object has methods that return the similarly named structure field name from the C's hostent structure from netdb.h; namely name, aliases, addrtype, length, and addr_list. The aliases and addr_list methods return array reference, the rest scalars. The addr method is equivalent to the zeroth element in the addr_list array reference. You may also import all the structure fields directly into your namespace as regular variables using the :FIELDS import tag. (Note that this still overrides your core functions.) Access these fields as variables named with a preceding "h_". Thus, "$host_obj->name()" corresponds to $h_name if you import the fields. Array references are available as regular array variables, so for example "@{ $host_obj->aliases() }" would be simply @h_aliases. The gethost() function is a simple front-end that forwards a numeric argument to gethostbyaddr() by way of Socket::inet_aton, and the rest to gethostbyname(). To access this functionality without the core overrides, pass the "use" an empty import list, and then access function functions with their full qualified names. On the other hand, the built-ins are still available via the "CORE::" pseudo-package. EXAMPLES
use Net::hostent; use Socket; @ARGV = ('netscape.com') unless @ARGV; for $host ( @ARGV ) { unless ($h = gethost($host)) { warn "$0: no such host: $host "; next; } printf " %s is %s%s ", $host, lc($h->name) eq lc($host) ? "" : "*really* ", $h->name; print " aliases are ", join(", ", @{$h->aliases}), " " if @{$h->aliases}; if ( @{$h->addr_list} > 1 ) { my $i; for $addr ( @{$h->addr_list} ) { printf " addr #%d is [%s] ", $i++, inet_ntoa($addr); } } else { printf " address is [%s] ", inet_ntoa($h->addr); } if ($h = gethostbyaddr($h->addr)) { if (lc($h->name) ne lc($host)) { printf " That addr reverses to host %s! ", $h->name; $host = $h->name; redo; } } } NOTE
While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. AUTHOR
Tom Christiansen perl v5.18.2 2013-11-04 Net::hostent(3pm)
All times are GMT -4. The time now is 02:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy