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

Re: ip local using gambas resources?


Hello,

May be this little function can help you:

Public Function getActiveNetworkInterface() As String

  ' Procedure to  check the Active Network Cards

  Dim tmpNIF As String[]
  Dim tmpActive, tmpString As String
  Dim iterator As Integer
  Dim tmpFile As File

  'get the interface directories
  tmpNIF = Dir("/sys/class/net")

  'check each folder's oper file to see if the interface is up and running
  For iterator = 0 To tmpNIF.Count - 1
   tmpString = "/sys/class/net" &/ tmpNIF[iterator] &/ "operstate"

   'check the operational state of each interface

    tmpFile = Open tmpString For Input

    While Not Eof(tmpFile)
      Line Input #tmpFile, tmpActive
    Wend

    Close #tmpFile

    'if it's reported as up then return it's name
    If tmpActive = "up" Then Return tmpNIF[iterator]
  Next

End

Olivier


> Le 23 févr. 2025 à 11:38, gaucho <64xcode@xxxxxxxxx> a écrit :
> 
> Hi, 
> 
> I am using shell command to obtain the ip address but. Is there a
> gambas native method to obtain the ip address in a pc connected to a
> local network but no internet available?
> 
> Thanks.
> Martin.
> 
> 


Follow-Ups:
Re: ip local using gambas resources?Fabien Bodard <gambas.fr@xxxxxxxxx>
References:
ip local using gambas resources?gaucho <64xcode@xxxxxxxxx>