diff --git a/pym/cl_utils.py b/pym/cl_utils.py index 7ae5015..93580e8 100644 --- a/pym/cl_utils.py +++ b/pym/cl_utils.py @@ -934,7 +934,7 @@ def getProgPath(progname): env = {"LANG":"C"} env.update(os.environ.items() + [("PATH",getpathenv())] +\ env.items()) - res = runOsCommand("which %s"%progname,env_dict=env) + res = runOsCommand("which %s"%baseprogname,env_dict=env) if res[0] == 0: return res[1][0].strip() elif path.isabs(progname) and path.exists(progname): diff --git a/pym/utils/ip.py b/pym/utils/ip.py index 37ba88f..8425cda 100644 --- a/pym/utils/ip.py +++ b/pym/utils/ip.py @@ -84,8 +84,10 @@ def checkMask(mask): def getIpAndMask(interface="eth0"): """Get ip and mask from interface""" - ifconfig = process('/sbin/ifconfig',interface) - res = re.search(r"inet addr:(\S+)\s.*Mask:(\S+)",ifconfig.read(),re.S) + ipconfigProg = checkUtils('/sbin/ifconfig') + ifconfig = process(ipconfigProg,interface) + res = re.search(r"inet(?: addr:| )(\S+)\s.*(?:Mask:|netmask )(\S+)", + ifconfig.read(),re.S) if res: return res.groups() else: @@ -139,7 +141,7 @@ def receiveMac(interface="eth0"): """Get MAC from interface""" ipconfigProg = checkUtils('/sbin/ifconfig') ifconfig = process(ipconfigProg,interface) - res = re.search(r"HWaddr\s(\S+)",ifconfig.read(),re.S) + res = re.search(r"(?:HWaddr|ether)\s(\S+)",ifconfig.read(),re.S) if res: return res.group(1) else: @@ -149,7 +151,8 @@ def receiveIpAndMask(interface="eth0"): """Get ip and mask from interface""" ipconfigProg = checkUtils('/sbin/ifconfig') ifconfig = process(ipconfigProg,interface) - res = re.search(r"inet addr:(\S+)\s.*Mask:(\S+)",ifconfig.read(),re.S) + res = re.search(r"inet(?: addr:| )(\S+)\s.*(?:Mask:|netmask )(\S+)", + ifconfig.read(),re.S) if res: return res.groups() else: