I have these two functions in my .bashrc file. You only need to run "ii" for the cool output. Now back to the question - If it is for linux only, why not just use the /sbin/ifconfig output. After all, it is accurate and seem much easier than all those libc/library methods. I pull the IPs and Interfaces available from the /sbin/ifconfig output and works just fine. If it was needed on windows, I am sure you could to the same thing with the 'ipconfig' output.
My 2c worth! :-) Regards, - Graeme - ------------ .bashrc --------------------- function my_ip() # get IP adresses { MY_IP=$(/sbin/ifconfig eth0 | awk '/inet/ { print $2 } ' | sed -e s/addr://) MY_ISP=$(/sbin/ifconfig ppp0 | awk '/P-t-P/ { print $3 } ' | sed -e s/P-t-P://) } function ii() # get current host related info { echo -e "\nYou are logged on ${RED}$HOST" echo -e "\nAdditionnal information:$NC " ; uname -a echo -e "\n${RED}Users logged on:$NC " ; w -h echo -e "\n${RED}Current date :$NC " ; date echo -e "\n${RED}Machine stats :$NC " ; uptime echo -e "\n${RED}Memory stats :$NC " ; free my_ip 2>&- ; echo -e "\n${RED}Local IP Address :$NC" ; echo ${MY_IP:-"Not connected"} echo -e "\n${RED}ISP Address :$NC" ; echo ${MY_ISP:-"Not connected"} echo } --------------------------------- On 06/10/06, Jeff Pohlmeyer <[EMAIL PROTECTED]> wrote:
> Better, but still Linux only. For a good solution, > a resolver unit that accesses libc should be > written that is portable (unlike the libc unit) If I understood correctly, the OP had two questions: 1. Retrieve a list of interface names on a *linux* system. 2. Return the IP address for a given *linux* interface name. And the only "good" solution is a portable resolver unit? How will you resolve "eth0" on Win32 or BSD ? -Jeff
-- There's no place like 127.0.0.1 _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal