Many thanks to the community
To reply to Graeme :
why not just use the /sbin/ifconfig output ?
Simply to be more dev compliance... using an external program is slower
and sometime ifconfig doesn't exist or is deleted on target computers.
To reply to Marco :
And the only "good" solution is a portable resolver unit?
How will you resolve "eth0" on Win32 or BSD ?
For WIN32, i d'ont care because the program is only for Linux systems.
Your are true, in BSD the network interface is not the same and i must
detect wich interface is used...
Best regards
Graeme Geldenhuys a écrit :
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
--
David Touzeau -------------------------- Linux Ubuntu Dapper 6.0.6
FreePascal-Lazarus,perl,delphi,php icq:160018849
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal