>}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: > [...] The script probably will not know either the domain name or the address of the machine on which it is running. Therefore you may have to open a connection to some remote site and ask it to tell you who you are using 'getsockname()'. The following works here: #!perl $remote = (gethostbyname('remote.host'))[4]; $p_add = pack('S n a4 x8', 2, $port, $remote); socket(SOCK, 2, 1, 6) or die "$!\n"; connect(SOCK, $p_add) or die "$!\n"; $myname = getsockname(SOCK); $myaddr = (unpack('S n a4 x8', $myname))[2]; $myaddr will then return the packed net address of the machine on which the script is running. [$port will of course depend on the server protocol, 'smtp, 'ftp' 'domain' or whatever, and can be looked up in 'getservbyname(PROTONAME, 'tcp')'] Hope this helps. Alan Fry >}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