From bc3a8c61fad8045b0b831a4ba61cf37a7f55842c Mon Sep 17 00:00:00 2001 From: Wouter Horlings Date: Sun, 17 Dec 2017 12:49:10 +0100 Subject: [PATCH] added windows for localIP --- Equipment/getLocalIP.m | 15 --------------- OOequipment/subfiles/getLocalIP.m | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) delete mode 100644 Equipment/getLocalIP.m create mode 100644 OOequipment/subfiles/getLocalIP.m diff --git a/Equipment/getLocalIP.m b/Equipment/getLocalIP.m deleted file mode 100644 index 4813b8d..0000000 --- a/Equipment/getLocalIP.m +++ /dev/null @@ -1,15 +0,0 @@ -function [ ipaddress ] = getLocalIP() -%GETLOCALIP returns the ipaddress of the current windows machine - [status,result]=system('ipconfig'); - if ~(status == 0) - error('Failed to find local IP address'); - end - [startIndex,endIndex] = regexp(result,'(?<=\n IPv4 Address[ \.]*: )([0-9]{1,3}\.?){4}'); - if isempty(startIndex) - error('Failed to find local IP address'); - end - for i = 1:length(startIndex) - ipaddress{i} = result(startIndex(i):endIndex(i)); - end -end - diff --git a/OOequipment/subfiles/getLocalIP.m b/OOequipment/subfiles/getLocalIP.m new file mode 100644 index 0000000..5604b0c --- /dev/null +++ b/OOequipment/subfiles/getLocalIP.m @@ -0,0 +1,20 @@ +function [ ipaddress ] = getLocalIP() +%GETLOCALIP returns the ipaddress of the current windows machine + if ispc + % Code to run on Windows plaform + [status,result]=system('ipconfig'); + if ~(status == 0) + error('Failed to find local IP address'); + end + [startIndex,endIndex] = regexp(result,'(?<=\n IPv4 Address[ \.]*: )([0-9]{1,3}\.?){4}'); + if isempty(startIndex) + error('Failed to find local IP address'); + end + for i = 1:length(startIndex) + ipaddress{i} = result(startIndex(i):endIndex(i)); + end + else + error('Function only available on Windows'); + end +end +