madhusudancs@gmail.com | 58f5056 | 2013-02-07 12:49:37 +0000 | [diff] [blame] | 1 | #get the OS |
| 2 | OS_NAME=`uname -a|awk '{print $1}'` |
| 3 | LINUX_OS='Linux' |
| 4 | |
| 5 | if [ $OS_NAME = $LINUX_OS ]; |
| 6 | then |
| 7 | #Get IP Address |
| 8 | IPADDR=`/sbin/ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'` |
madhusudancs@gmail.com | caf0833 | 2013-03-15 08:26:56 +0000 | [diff] [blame^] | 9 | if [ "$IPADDR" = "" ] |
| 10 | then |
| 11 | IPADDR=`/sbin/ifconfig em1 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'` |
| 12 | fi |
madhusudancs@gmail.com | 58f5056 | 2013-02-07 12:49:37 +0000 | [diff] [blame] | 13 | if [ "$IPADDR" = "" ] |
| 14 | then |
| 15 | IPADDR=`/sbin/ifconfig lo | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'` |
| 16 | fi |
| 17 | else |
| 18 | IPADDR=`/sbin/ifconfig en1 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'` |
| 19 | if [ "$IPADDR" = "" ] |
| 20 | then |
| 21 | IPADDR=`/sbin/ifconfig lo0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'` |
| 22 | fi |
| 23 | |
| 24 | fi |
| 25 | echo $IPADDR |