Get the active network interface

Author: Dimitrios Anogiatis

This function will give you the active network interface (ie eth0 or wlan0 etc)
It can be used in shell functions or any internal function that depends on this

    Public Function getActiveNetworkInterface() As String
    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
     Close #tmpFile
      'if it's reported as up then return it's name
      If tmpActive = "up" Then Return tmpNIF[iterator]