[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] TCP/IP address



At 9:01 AM -0800 on 11/4/96, Jason Lee wrote:


}Hi there,
}
}I have a script that wants to run over a dialup PPP connection. The script
}needs to know the TCP address of the mac on which it is running, but that
}address is dynamic, being set at connect time. How can one find that
}information from within macperl?

You really want the address, or just the name?

chomp($myname = `hostname`);
$myaddr = (gethostbyname($myname))[4];
$mynum = join(".",unpack(C4,$myaddr));
print "$myname $mynum\n";

gives me (correctly) at the moment on my dynamic PPP connection:

slip166-72-171-117.pa.us.ibm.net 166.72.171.117

Read the perlfunc.pod for additional information on gethostbyname, since it
returns other information you might be interested in.

}
}
}Thanks very much
}
}
}
}Jason
}
}
}
}
}Jason Lee               Pager  :  (310) 501.2136          Digital Domain
}Sys Admin               Phone  :  (310) 314.2887          300 Rose Ave
}english@d2.com          Fax    :  (310) 314.2888          Venice, Ca 90291


--------
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693
Greenbelt, MD 20770
schinder@leprss.gsfc.nasa.gov