blob: e0cdf736174d60486caba2f4d3a616abff8665fc [file] [log] [blame]
buyingyi98e9a9b2013-03-10 21:24:35 +00001#get the OS
2OS_NAME=`uname -a|awk '{print $1}'`
3LINUX_OS='Linux'
4
5if [ $OS_NAME = $LINUX_OS ];
6then
7 #Get IP Address
8 IPADDR=`/sbin/ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
9 if [ "$IPADDR" = "" ]
10 then
11 IPADDR=`/sbin/ifconfig lo | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
12 fi
13else
14 IPADDR=`/sbin/ifconfig en1 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
15 if [ "$IPADDR" = "" ]
16 then
17 IPADDR=`/sbin/ifconfig lo0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
18 fi
19
20fi
21echo $IPADDR