ftao / python-ifcfg

Python cross-platform network interface discovery (ifconfig/ipconfig/ip)
BSD 3-Clause "New" or "Revised" License
55 stars 37 forks source link

PATH variable should be considered in Parser #64

Open mobangjack opened 3 years ago

mobangjack commented 3 years ago

class UnixParser(Parser):

@classmethod
def get_command(cls):
    ifconfig_cmd = 'ifconfig'
    for path in ['/sbin', '/usr/sbin', '/bin', '/usr/bin']: // PATH variable should be considered
        if os.path.exists(os.path.join(path, ifconfig_cmd)):
            ifconfig_cmd = os.path.join(path, ifconfig_cmd)
            break
    ifconfig_cmd = ifconfig_cmd + " -a"
    return ifconfig_cmd
benjaoming commented 3 years ago

Sounds like a great idea :+1:

You are welcome to look into this :+1: