Re: tell the difference between url and ip address

From: Michael Heiming (michael+USENET_at_www.heiming.de)
Date: 06/25/05


Date: Sat, 25 Jun 2005 10:40:46 +0200

In comp.unix.shell John W. Krahn <someone@example.com>:
> Michael Heiming wrote:
>> In comp.unix.shell Robert Bonomi <bonomi@host122.r-bonomi.com>:
>>
>>>In article <u6auo2-4jm.ln1@rogers.com>,
>>>Chris F.A. Johnson <cfajohnson@gmail.com> wrote:
>>>
>>>>On 2005-06-24, juicymixx@mailinator.com wrote:
>>>>
>>>>>is there a nifty command line way (in bash) to tell the difference
>>>>>between an ip address and a url?
[..]

>>>Shall we mention IPv6? <evil grin>
>>
>> Perl seems to be the easiest, despite requiring Validate::Net,
>> dunno if it works with IPv6.
>>
>> perl -MValidate::Net -le'print !Validate::Net->ip("216.239.39.99")&&"in","valid"'
>>
>> Don't have Validate::Net installed right now.

> You don't have to install it, you can use the Socket module which is installed
> with Perl:

> perl -MSocket -le'eval { inet_ntoa inet_aton "216.239.39.99" }; print $@ &&
> "in", "valid"'

Ah, great info! Works fine for IPv4 not for IPv6.

-- 
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo zvpunry@urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
#bofh excuse 73: Daemons did it


Relevant Pages

  • Re: Stats comp.os.linux.networking (last 7 days)
    ... Dunno, don't use my MUA for usenet. ... GUI newsreader. ... Should be in the stats, ... Michael Heiming ...
    (comp.os.linux.networking)
  • Re: OT: Most clueless ISP award?
    ... Michael Heiming wrote: ... Dunno if there is such a prize but I'd give it to verizon.net for ... (Although that usually uses one of the "temporary" error codes in the SMTP protocol.) ...
    (comp.os.linux.misc)
  • Re: Kernel 2.6.9 performance?
    ... Michael Heiming wrote: ... It's exactly as written, dunno what there is ... > to misinterpret about it? ... Paul ...
    (comp.os.linux.misc)
  • Re: {Q} REDHAT AS 3.0 bootable modules different than AS 2.1?
    ... dunno what your problem is? ... Please stop top-posting, thx. ... Michael Heiming ...
    (comp.os.linux.misc)
  • Re: installing new software
    ... >> The speediest thing is the IPv6 disabling, dunno that much of the other ... > Never had an issue with IPv6, ... I have noticed a really significant difference in solving hosts with or ... Dunno really. ...
    (alt.os.linux.suse)