activate and deactivate

hi all

by using gethostbyname, i can know whether the net is available or not.
it is working fine when i activate or deactivate in neat.
the problem is when i remove cable(netcable) it is not working proparly,

i would like to know it.
am using fedora5, AMD
can u please help me .

thank you.

I'm kinda confused on what exactly you are trying to achive. Is this "getbyhostname" used in Perl script ? On command line there are lots of utilites : ping, traceroute, mtr, tcptraceroute, and my favorite :

[root@sysgate ~]$ gethostip unix.com
unix.com 216.120.251.184 D878FBB8

Please explain in details.

I just found this in my archive :

#!/usr/local/bin/perl

use strict;
use warnings;

use Socket qw(AF_INET);

usage() if $#ARGV == -1;
display_info( @ARGV );

sub display_info {
  foreach (shift) {
    my ($ip, $host, $aliases, $addrtype, $length, @addrs);
    $ip = $_;
    if ( /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ ) {
      print "IP is $ip\n";
      ($host, $aliases, $addrtype, $length, @addrs) =
         gethostbyaddr( pack( 'C4', $1, $2, $3, $4 ), AF_INET );
      die "Reverse lookup failed to find name for $ip\n" unless $host;
    }
    $host = $ip unless $host;
    print "Hostname is $host\n";
    ($host, $aliases, $addrtype, $length, @addrs) = gethostbyname( $host );
    die "Lookup failed to find address for $host\n" unless @addrs;
    print "Maps to these IPs:\n";
    foreach (@addrs) {
      print "IP: ".join( '.', unpack( 'C4', $_ ) )."\n";
    }
  }
}

sub usage {
  print STDERR <<EOM;
Usage: getdnsinfo.pl <IP|host>...
Example `getdnsinfo.pl domain.com'
EOM
  exit( 0 );
}

Is it something similar that you are doing ?

it is amazing.

but still have a problem

when i typed in terminal gethostip unix.com

is working,when i remove the cable(connection) at the cpu.

it not working. it very slow. what can i do.

to work it fast.

help me.

thank you

Um, which cable you're removing ? The NIC cable ? How come then you have connection, or I'm wrong ......