[fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

Jeff Pohlmeyer yetanothergeek at gmail.com
Fri Oct 6 13:26:48 CEST 2006


> how can i list wich interface loaded without
> need to parse /etc/networks/...?



I would parse /proc/net/dev instead....


program ifnames;
var
  s:shortstring;
  f:text;
  p:LongInt;
begin
  assign(f,'/proc/net/dev');
  reset(f);
  while not eof(f) do begin
    readln(f,s);
    p:=pos(':',s);
    if ( p > 0 ) then begin
      delete(s, p, 255);
      while ( s <> '' ) and (s[1]=#32) do delete(s,1,1);
      writeln(s);
    end;
  end;
  close(f);
end.



More information about the fpc-pascal mailing list